templates

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2016 License: MIT Imports: 16 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CAMEL_CASE_REGEX = regexp.MustCompile(
	"(^([[:lower:]]|[[:digit:]])+)|" +

		"([[:upper:]]*([[:lower:]]|[[:digit:]]|$)*)") // Handle normal camel case

This regex can be used to split CamelCase strings into "words". That is, given a string like FooBarBaz, you can use this regex to split it into an array ["Foo", "Bar", "Baz"]. It also handles lower camel case, which is the same as camel case, except it starts with a lower case word, such as fooBarBaz.

To capture lowercase camel case, we just look for words that consist of lower case letters and digits at the start of the string. To capture all other camel case, we look for "words" that start with one or more consecutive upper case letters followed by one or more lower case letters or digits.

View Source
var PUNCTUATION_OR_WHITESPACE_REGEX = regexp.MustCompile("([[:space:]]|[[:punct:]])+")
View Source
var SNIPPET_MARKER_REGEX = regexp.MustCompile("boilerplate-snippet:\\s*(.+?)(?:\\s|$)")
View Source
var WHITESPACE_REGEX = regexp.MustCompile("[[:space:]]+")

Functions

func CreateTemplateHelpers

func CreateTemplateHelpers(templatePath string) template.FuncMap

Create a map of custom template helpers exposed by boilerplate

func ProcessTemplate added in v0.0.6

func ProcessTemplate(options *config.BoilerplateOptions) error

Process the boilerplate template specified in the given options and use the existing variables. This function will load any missing variables (either from command line options or by prompting the user), execute all the dependent boilerplate templates, and then execute this template.

Types

type InvalidSnippetArguments

type InvalidSnippetArguments []string

func (InvalidSnippetArguments) Error

func (args InvalidSnippetArguments) Error() string

type SnippetNotFound

type SnippetNotFound string

func (SnippetNotFound) Error

func (snippetName SnippetNotFound) Error() string

type SnippetNotTerminated

type SnippetNotTerminated string

func (SnippetNotTerminated) Error

func (snippetName SnippetNotTerminated) Error() string

type TemplateHelper

type TemplateHelper func(templatePath string, args ...string) (string, error)

All boilerplate template helpers implement this signature. They get the path of the template they are rendering as the first arg and then any arguments the user passed when calling the helper.

Jump to

Keyboard shortcuts

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