// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // package template wraps the golang "text/template" package to provide an // enhanced template generator. package template import ( "fmt" "io" "io/ioutil" "path/filepath" "strings" "text/template" "unicode" "dawn.googlesource.com/dawn/tools/src/fileutils" ) // The template function binding table type Functions map[string]interface{} // Run executes the template tmpl, writing the output to w. // funcs are the functions provided to the template. // See https://golang.org/pkg/text/template/ for documentation on the template // syntax. func Run(tmpl string, w io.Writer, funcs Functions) error { g := generator{ template: template.New("