vuetemplate

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package vuetemplate allows to serve vue.js apps over a go api. The abstraction works over different elements:

  • JSType defines the different statements, which are used inside JS
  • JSElement is a full JavaScript statement for example `var v1 = "val";`
  • Vue is the definition of the vue object
  • Component defines a vue component

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component struct {
	Vue
	Name string
}

Component is used for vuejs components

func NewComponent

func NewComponent(name string) *Component

NewComponent creates a component and returns the pointer

func (*Component) WriteTo

func (c *Component) WriteTo(w io.Writer) (int64, error)

WriteTo implements the WriterTo interface. It takes a io.Writer and writes the js block into the writer.

type JSElement

type JSElement struct {
	JSType  JSType
	VarName string
	Value   string
}

JSElement represents the different variable declarations of JS.

func NewJSElement

func NewJSElement(t JSType, name, value string) *JSElement

func (JSElement) Create

func (jse JSElement) Create(w io.Writer, wt io.WriterTo)

func (*JSElement) String

func (jse *JSElement) String() string

String creates a JS line for the element

func (*JSElement) Write

func (jse *JSElement) Write(p []byte) (n int, err error)

Write implements the io.Writer. The write method writes everything into the jse.Value

func (*JSElement) WriteTo

func (jse *JSElement) WriteTo(w io.Writer) (int64, error)

WriteTo implements the io.WriterTo interface by wrapping the String() function. WriteTo makes it easier to serve the data inside of a http handler.

type JSType

type JSType int
const (
	CONSTANT JSType = iota
	VARIABLE
	LETSTMT
	FUNCTION
	WEBSOCKET
	VUECOMPONENT
	VUEAPP
	VUEROUTER
)

type Router

type Router struct {
	Routes []Vue
	Name   string
}

func NewRouter

func NewRouter(name string, routes []Vue) *Router

func (*Router) WriteTo

func (r *Router) WriteTo(w io.Writer) (int64, error)

type Vue

type Vue struct {
	Template     string // vue template also used inside components
	Data         string
	Name         string // just used inside router definition
	Props        string // for handling values inside components
	Children     string // used inside components
	Components   string // used inside components
	Computed     string
	Methods      string
	Watch        string
	BeforeMount  string
	Mounted      string
	BeforeUpdate string
	Updated      string
	Path         string // just used inside routes
}

Vue defines all possible JS objects used with vue.js. There are not only the core elements availiable. Route and component properties are added here, too.

func NewVue

func NewVue() Vue

func (*Vue) WriteTo

func (v *Vue) WriteTo(w io.Writer) (int64, error)

Jump to

Keyboard shortcuts

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