petra

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2021 License: MIT Imports: 19 Imported by: 0

README

Petra

An experiment in server-side rendering in Go.

Goals

  • Make dynamic server-side rendering easy and fast, leveraging existing Go/web tooling where applicable.
  • Bring a component-based approach to views.
  • Leverage TailwindCSS using JIT compiler for
  • Robust CLI for generating components, JIT CSS, hot-reload, etc.

IMPORTANT: This project is still very much in the experimental phase. Everything is subject to change. The current focus is dialing in the desired workflows. Once the desired workflows are achieved, the code will be optimized, tested, and cleaned up.

Getting Started

TBD

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTemplateNotFound = errors.New("Not found")
)

Functions

This section is empty.

Types

type Application

type Application struct {
	chi.Router
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) *Application

type Component

type Component struct {
	Mount page.MountHandler
	// contains filtered or unexported fields
}

func NewComponent

func NewComponent(name string, route *Route, self interface{}) *Component

func (*Component) Build

func (r *Component) Build(c *page.Component) (*page.Component, error)

func (*Component) Register

func (r *Component) Register(f func(c *page.Component) error)

func (*Component) Render

func (r *Component) Render(w io.Writer, cmp *page.Component) error

func (*Component) Session

func (r *Component) Session(s live.SessionStore)

func (*Component) Validate

func (r *Component) Validate() error

type Option

type Option func(a *Application)

func HotReload

func HotReload(v bool) Option

func Root

func Root(root embed.FS) Option

func SessionStore

func SessionStore(sessionName string, keyPairs ...[]byte) Option

type Route

type Route struct {
	Register page.RegisterHandler
	Mount    page.MountHandler
	// contains filtered or unexported fields
}

func NewRoute

func NewRoute(name string, app *Application, self interface{}) *Route

func (*Route) Handler

func (r *Route) Handler() (*live.Handler, error)

func (*Route) Render

func (r *Route) Render(w io.Writer, cmp *page.Component) error

func (*Route) Session

func (r *Route) Session(s live.SessionStore)

func (*Route) Validate

func (r *Route) Validate() error

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router does the following - Loads and parses templates

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL