Beispiel #1
0
func compileTemplate(data []byte, name string) *structure.Helper {
	baseHelper := structure.Helper{Name: name, Arguments: nil, Unescaped: false, Position: 0, Block: []byte{}, Children: nil, Function: getFunction(name)}
	allHelpers := make([]structure.Helper, 0)
	data, allHelpers = findHelper(data, allHelpers)
	baseHelper.Block = data
	baseHelper.Children = allHelpers
	// Handle extend helpers
	for index, child := range baseHelper.Children {
		if child.Name == "body" {
			baseHelper.BodyHelper = &baseHelper.Children[index] //TODO: This handles only one body helper per hbs file. That is a potential bug source, but no theme should be using more than one per file anyway.
		}
	}
	return &baseHelper
}