statictemplate

Statictemplate is a code generator for Go's text/template and html/template.

  • Owner: bouk/statictemplate
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

statictemplate

Statictemplate is a code generator for Go's text/template and html/template packages. It works by reading in the template files, and generating the needed functions based on the combination of requested function names and type signatures.

Please read my blogpost about this project for some background.

Installation

To install the commandline tool, run go get bou.ke/statictemplate.

Usage

These are the supported flags:

Usage of statictemplate:
  -dev string
        Name of the dev output file
  -funcs string
        A reference to a custom Funcs map to include
  -html
        Interpret templates as HTML, to enable Go's automatic HTML escaping
  -o string
        Name of the output file (default "template.go")
  -package string
        Name of the package of the result file. Defaults to name of the folder of the output file
  -t value
        Target to process, supports multiple. The format is <function name>:<template name>:<type of the template argument>

After the flags you pass in one or more globs to specify the templates.

The example in this project uses the following command

statictemplate -html -o example/template/template.go -t "Index:index.tmpl:[]bou.ke/statictemplate/example.Post" example/template/*.tmpl

Docs

Check out the docs.

Main metrics

Overview
Name With Ownerbouk/statictemplate
Primary LanguageGo
Program languageGo (Language Count: 3)
Platform
License:MIT License
所有者活动
Created At2016-09-02 17:16:37
Pushed At2018-08-21 12:20:56
Last Commit At2018-08-21 14:20:55
Release Count0
用户参与
Stargazers Count80
Watchers Count1
Fork Count5
Commits Count36
Has Issues Enabled
Issues Count4
Issue Open Count3
Pull Requests Count2
Pull Requests Open Count0
Pull Requests Close Count0
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private