vueg

command module
v0.0.0-...-5b20696 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2021 License: MIT Imports: 11 Imported by: 0

README

vueg

Command vueg is the Go generator for Vue templates.

Install

go get github.com/norunners/vueg

Hello World!

The mainTmpl.vue Vue template file is read to generate Go source.

<template>
    <div>{{ Message }}</div>
</template>

The main.go file declares the //go:generate vueg directive. Note, the constant mainTmpl is expected to be generated.

package main

import "github.com/norunners/vue"

//go:generate vueg

type Data struct {
	Message string
}

func main() {
	vue.New(
		vue.El("#app"),
		vue.Template(mainTmpl),
		vue.Data(Data{Message: "Hello WebAssembly!"}),
	)

	select {}
}

Run vueg with the following command.

go generate

Finally, the mainTmpl.go file is generated with the mainTmpl constant.

// The vueg command generated this source from file: mainTmpl.vue, do not edit.

package main

const mainTmpl = "<div>{{ Message }}</div>"

File Watching

Below is the vueg file watcher setup in GoLand. The file watcher runs go generate after changes are made to Go files. Note, this configuration does not listen to changes on the Vue template files themselves. Other IDEs that support file watchers may be configured similarly. file-watcher

Styling

The vueg command does not currently support the <style> element in Vue templates. The goal is to support scoped styling in the future.

License

Documentation

Overview

Package main is vueg - The Go generator for Vue templates. The vueg command expects to be called by go generate. Vue template files with the .vue extension are generated into constants in Go source. This lets the template constant be available to use in Vue template options.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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