summaryrefslogtreecommitdiffstats
path: root/tpl/template_test.go
AgeCommit message (Collapse)Author
2019-12-12Create lightweight forks of text/template and html/templateBjørn Erik Pedersen
This commit also removes support for Ace and Amber templates. Updates #6594
2019-08-12tests: Convert from testify to quicktestBjørn Erik Pedersen
2018-10-16commands: Show server error info in browserBjørn Erik Pedersen
The main item in this commit is showing of errors with a file context when running `hugo server`. This can be turned off: `hugo server --disableBrowserError` (can also be set in `config.toml`). But to get there, the error handling in Hugo needed a revision. There are some items left TODO for commits soon to follow, most notable errors in content and config files. Fixes #5284 Fixes #5290 See #5325 See #5324
2017-02-17tpl: Refactor packageBjørn Erik Pedersen
Now: * The template API lives in /tpl * The rest lives in /tpl/tplimpl This is bound te be more improved in the future. Updates #2701
2017-02-17all: Refactor to nonglobal Viper, i18n etc.Bjørn Erik Pedersen
This is a final rewrite that removes all the global state in Hugo, which also enables the use if `t.Parallel` in tests. Updates #2701 Fixes #3016
2017-02-15Use OS fs by defaultBjørn Erik Pedersen
Fixes #3032
2017-02-04all: Refactor to nonglobal file systemsBjørn Erik Pedersen
Updates #2701 Fixes #2951
2017-01-10 all: Refactor to nonglobal template handlingBjørn Erik Pedersen
Updates #2701
2017-01-07all: Refactor to non-global loggerBjørn Erik Pedersen
Note that this looks like overkill for just the logger, and that is correct, but this will make sense once we start with the template handling etc. Updates #2701
2016-03-31Add readFile template funcBjørn Erik Pedersen
This also includes a refactor of the hugofs package and its usage. The motivation for that is: The Afero filesystems are brilliant. Hugo's way of adding a dozen of global variables for the different filesystems was a mistake. In readFile (and also in some other places in Hugo today) we need a way to restrict the access inside the working dir. We could use ioutil.ReadFile and implement the path checking, checking the base path and the dots ("..") etc. But it is obviously better to use an Afero BasePathFs combined witha ReadOnlyFs. We could create a use-once-filesystem and handle the initialization ourselves, but since this is also useful to others and the initialization depends on some other global state (which would mean to create a new file system on every invocation), we might as well do it properly and encapsulate the predefined set of filesystems. This change also leads the way, if needed, to encapsulate the file systems in a struct, making it possible to have several file system sets in action at once (parallel multilanguage site building? With Moore's law and all...) Fixes #1551
2016-03-17tpl: Add missing printf param in t.Errorf callCameron Moore
2016-03-10Add support for Go 1.6 block keyword in templatesBjørn Erik Pedersen
NOTE: Needs Go 1.6 to use the new feature. Fixes #1832
2016-01-13Add one more temporary template test for linux/armBjørn Erik Pedersen
See #1771
2016-01-13Add temporary template test for linux/armBjørn Erik Pedersen
See #1771
2015-12-10Add copyright header to that source files that don’t have one.Anthony Fok
See #1646
2015-05-31Add some Ace test casesbep
See #1178
2015-05-02Disable faulty range validation in applybep
Fixed #1098
2015-05-01tpl: check that types in args match the target func's typebep
Fixes #1095
2015-04-30tpl: add sanity check to prevent panic in seq on big numsbep
Fixes #1092
2015-04-30tpl: check for too many arguments in applybep
Fixes #1091
2015-04-30tpl: check slice bounds in slicestrbep
Fixes #1090
2015-04-30tpl: avoid panic on too few args to applybep
Fixes #1089
2015-04-05tpl: split template.gobep
The template funcs get their own file. This prevents having to scroll miles to get to the template infrastructure.
2015-04-01Remove paragraph tags produced by markdownifybep
Fixes #1025
2015-03-23Change to variadic int args in Slicestrbep
Makes for a better template api.
2015-03-23Implement substr template functionAnthony Fok
Its behavior is similar to that in JavaScript with special handling of negative length as found in in PHP. Fixes #991
2015-03-23Rename Slice to Slicestrbep
Fixes #990
2015-03-23Rename Substr to Slicebep
That is whas was implemented, not Substr. Also make the API more similar to Go's internal slice by making both the start and end indices optional. See #990
2015-03-22Polish Substr and Split testsbep
2015-03-22Add Substr and Split template functionsXin Fan
Both of these can take any type the cast lib can turn into a string.
2015-03-18template: add some missing test cases for Firstbep
2015-03-18More initialism corrections (golint)Anthony Fok
Thanks to @bep's new, brilliant helpers.Deprecated() function, the following functions or variables are transitioned to their new names, preserving backward compatibility for v0.14 and warning the user of upcoming obsolescence in v0.15: * .Url → .URL (for node, menu and paginator) * .Site.BaseUrl → .Site.BaseURL * .Site.Indexes → .Site.Taxonomies * .Site.Recent → .Site.Pages * getJson → getJSON * getCsv → getCSV * safeHtml → safeHTML * safeCss → safeCSS * safeUrl → safeURL Also fix related initialisms in strings and comments. Continued effort in fixing #959.
2015-03-11Correct initialisms as suggested by golintAnthony Fok
First step to use initialisms that golint suggests, for example: Line 116: func GetHtmlRenderer should be GetHTMLRenderer as see on http://goreportcard.com/report/spf13/hugo Thanks to @bep for the idea! Note that command-line flags (cobra and pflag) as well as struct fields like .BaseUrl and .Url that are used in Go HTML templates need more work to maintain backward-compatibility, and thus are NOT yet dealt with in this commit. First step in fixing #959.
2015-03-11doArithmetic: add test for division by zerobep
2015-03-11Add some basic tests for doArithmeticbep
We might have to take precision into account for floating point nubers ... at some point.
2015-03-09Add test cases for Ne and Eq type normalisationbep
See #961
2015-03-06Fix errors reported by Go Vetbep
2015-03-05Apply gofmt -sbep
2015-01-31Add writable context to Nodebep
The variable scope in the Go templates makes it hard, if possible at all, to write templates with counter variables or similar state. This commit fixes that by adding a writable context to Node, backed by a map: Scratch. This context has three methods, Get, Set and Add. The Add is tailored for counter variables, but can be used for any built-in numeric values or strings.
2015-01-22Add dateFormat template functionTatsushi Demachi
This is the implementation of the proposal at #235 and http://discuss.gohugo.io/t/parsing-dates-in-templates/603/3
2015-01-20Add missing assertion to trim-testbep
2015-01-20Add tests for IsSetbep
2015-01-20Refactor TestGt to also include Lt, Ge, Le, Eq and Nebep
2015-01-20Add tests for Applybep
2015-01-20Replace regexp based Chomp with builtin TrimRightbep
2015-01-20Add tests for Replacebep
2015-01-20Add tests for Trimbep
2015-01-20Add tests for Chompbep
2015-01-19Add `safeUrl`; disable `safeHtmlAttr`; rename `safeCSS` to `safeCss`Anthony Fok
- Add `safeUrl` template function (Fixes #347) - Add TestSafeUrl() fashioned after @tatsushid great examples - Disable `safeHtmlAttr` pending further discussions on its other use cases because `safeUrl` is a cleaner solution to #347. (There are also `safeJs` and `safeJsStr` that we could implement if there are legitimate demands for them.) - Rename `safeCSS` to `safeCss` (to follow the convention of `safeHtml`) - Add/expand documentation on `safeHtml`, `safeCss` and `safeUrl`
2015-01-19Add SafeHtmlAttr, SafeCSS template functionTatsushi Demachi
This allows a template user to keep a safe HTML attribute or CSS string as is in a template. This is implementation of @anthonyfok great insight Fix #784, #347