Skip to content
프로젝트

소개

Go로 만드는 비동기 HTML 컴포넌트

웹 및 앱 개발

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
-1
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

kyoto

Go server side frontend framework

import "github.com/yznts/kyoto/v3"

Kyoto is a library for creating fast, server side frontend avoiding vanilla templating downsides.

It tries to address complexities in frontend domain like responsibility separation, components structure, asynchronous load and hassle-free dynamic layout updates. These issues are common for frontends written with Go.

The library provides you with primitives for pages and components creation, state and rendering management, dynamic layout updates (with client configuration), utility functions and asynchronous components out of the box. Still, it bundles with minimal dependencies and tries to utilize built-ins as much as possible.

You would probably want to opt out from this library in few cases, like, if you're not ready for drastic API changes between major version, you want to develop SPA/PWA and/or complex client-side logic, or you're just feeling OK with your current setup. Please, don't compare kyoto with a popular JS libraries like React, Vue or Svelte. I know you will have such a desire, but most likely you will be wrong. Use cases and underlying principles are just too different.

If you want to get an idea of what a typical static component would look like, here's some sample code. It's very ascetic and simplistic, as we don't want to overload you with implementation details. Markup is also not included here (it's just a well-known `html/template`).

// State is declared separately from component itself
type ComponentState struct {
	// We're providing component with some abilities here
	component.Universal // This component uses universal state, that can be (un)marshalled with both server and client

	// Actual component state is just struct fields
	Foo string
	Bar string
}

// Component is a function, that returns configured state.
// To be able to provide additional arguments to the component on initialization,
// you have to wrap component with additional function that will handle args and return actual component.
// Until then, you may keep component declaration as-is.
func Component(ctx *component.Context) component.State {
	// Initialize state here.
	// As far as component.Universal provided in declaration,
	// we're implementing component.State interface.
	state := &ComponentState{}
	// Do whatever you want with a state
	state.Foo = "foo"
	state.Bar = "bar"
	// Done
	return state
}

For details, please check the library index to explore available sub-packages and https://pkg.go.dev for Go'ish documentation style.

관련 프로젝트 살펴보기

불러오는 중…