Commit graph

55 commits

Author SHA1 Message Date
Cameron Moore
45df4596bb tpl: Add humanize func and cleanup lint
Add humanize (inflect.Humanize) to the template funcMap.  Documentation and
tests are included.

Various code cleanups of the template funcs:

- Break pluralize and singularize out into stand-alone funcs.
- Sort the list of funcMap entries.
- Add some minimal godoc comments to all public funcs.
- Fix some issues found by golint and grind.
2016-02-06 15:31:25 +01:00
Bjørn Erik Pedersen
58a183c330 Docs: Add doc for string and int 2016-01-16 00:06:32 +01:00
Bjørn Erik Pedersen
01f71babfc docs: Add lastmod to content files
Based on last commit in Git.
2016-01-06 23:55:18 +01:00
digitalcraftsman
dfa34afd86 Add template funcs countwords and countrunes 2016-01-02 11:00:03 -05:00
Anthony Fok
cb8f459127 Docs: Add nohighlight shortcode and improve formatting
And some random formatting and copyediting fixes.

See also #1708
2015-12-23 09:31:07 -07:00
Maxime Michel
38c5db98b5 Added a missing closing tag 2015-12-11 10:51:17 -07:00
Gustav Näslund
b0b6a8c7ac Use .Site.Pages in the documentation examples instead of .Site.Recent 2015-11-30 23:31:18 -07:00
Anthony Fok
e59aabcf46 docs: Change "Github" to "GitHub" 2015-11-20 14:24:22 -07:00
digitalcraftsman
a5bd101d27 Docs: fix typo in template function section 2015-11-20 13:30:27 -07:00
Cameron Moore
c5a4c07b89 Add SafeJS template function
This commit adds a SafeJS template function.  Tests and documentation are
included.

Fixes #1579
2015-11-20 21:12:01 +01:00
Tobias
4e9a5d8bd1 Fix some typos in docs 2015-10-17 13:48:10 +02:00
NotZippy
3a27cefec1 Add dictionary function to be passed into a template
Allows templates to dynamically build maps.

Example usage: Creating and passing a map to a subtemplate while in a range on the parent.
2015-10-09 18:29:16 +02:00
digitalcraftsman
79f8bb625d Add base64Decode and base64Encode template functions
Fixes #1416
2015-09-25 21:31:55 +02:00
Bjørn Erik Pedersen
82f770a6f5 Remove superfluous g in docs 2015-09-23 09:18:20 +02:00
Bjørn Erik Pedersen
06caa025a4 Fix typo in docs
See #1438
2015-09-22 22:33:41 +02:00
Bjørn Erik Pedersen
8d695ec592 Add singularize template func
See #1438
2015-09-22 22:31:02 +02:00
Bjørn Erik Pedersen
751d4906ef Add pluralize template func
Fixes #1438
2015-09-22 22:25:25 +02:00
Benny Wu
d313bc78a4 Documentation update on Template Where Function for nil 2015-08-13 23:05:10 +02:00
Anthony Fok
5505ac0d72 doc: Strip trailing whitespace; other revisions
Make some random and non-comprehensive changes to the
template functions documentation to make them more
consistent.
2015-08-04 12:00:08 -06:00
Ariejan de Vroom
cc9536ec46 Update docs for last template function 2015-06-15 21:18:38 +02:00
Ariejan de Vroom
40a92a062d Add after to template function documentation 2015-06-15 21:18:38 +02:00
bep
be778c3160 docs: some more on absURL, relURL 2015-05-22 23:43:02 +02:00
bep
be1366074c docs: add doc for substr
Fixes #1156
2015-05-22 22:36:25 +02:00
bep
be4376a022 docs: add doc for slicestr
See #1156
2015-05-22 22:20:45 +02:00
bep
be2e08c4ad docs: add doc for seq
See #1156
2015-05-22 22:17:41 +02:00
Jeff Ramnani
7125103b1e Add ".Render" to the list of functions.
Fixes: #1153
2015-05-22 19:38:01 +02:00
bep
be82355570 Add doc for absURL and relURL
Also group URL related functions in doc.
2015-05-11 19:09:04 +02:00
bep
be4f48652d Add ToC to long pages
* A compact, fixed box in the right screen
* Only for big screens, > 1200 px wide
2015-05-11 18:39:42 +02:00
mdhender
42dcaabf4f Document getenv template function
Add `getenv` to the template function documentation.
2015-04-05 18:14:40 +02:00
mdhender
6b50c8fb82 Sort function names in templates documentation
The documentation on the functions is long.  It is easier to find
a function name when they are sorted within the sections.

Fixes #981
2015-04-04 23:30:08 +02:00
Anthony Fok
b3bd71fec9 Update Hugo docs with the initialisms suggested by golint
In particular:

 * .Url → .URL (for node, menu and paginator)
 * .Site.BaseUrl → .Site.BaseURL
 * getJson → getJSON
 * getCsv → getCSV
 * safeHtml → safeHTML
 * safeCss → safeCSS
 * safeUrl → safeURL

Continued effort in fixing #959.
2015-03-18 11:30:37 +01:00
Anthony Fok
ba44e860a3 [Docs] Copyediting
* Add meta author, description and generator tags
 * Add Hugo version beside the logo and in the footer
 * Suggest the user to run `go get -u -v` to update dependencies
 * Requires Go 1.3+ rather than Go 1.1+
 * Improve rendering/formatting in some places
 * Add trailing slash to URLs where appropriate
 * GitHub redirects all http requests to https, update accordingly
2015-01-28 18:02:40 -07:00
Tatsushi Demachi
37490ee27a Add dateFormat template function
This is the implementation of the proposal at #235 and
http://discuss.gohugo.io/t/parsing-dates-in-templates/603/3
2015-01-22 00:08:30 +01:00
Anthony Fok
2342655fde [Docs] Incorporate some great ideas by @mohae into the safeUrl docs
E.g. how `#ZgotomlZ` is used to "defang" the URL
2015-01-20 00:24:47 -07:00
Anthony Fok
724cc0ddff Add safeUrl; disable safeHtmlAttr; rename safeCSS to safeCss
- 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-19 23:41:22 -07:00
Anthony Fok
1dfd0225e3 [Docs] Minor revisions to future v0.13 Release Note
And a tiny bit of copyediting here and there.
2015-01-18 13:27:09 -07:00
Tom Helmer Hansen
871e811339 Add trim and replace template functions 2015-01-18 14:54:26 +01:00
Anthony Fok
b59dd163ec [Docs] More copyediting
* Add link to https://travis-ci.org/spf13/hugo
* Correct heading levels in docs/content/community/mailing-list.md
* Mention RFC 3339 as the `date` format set by `hugo new`
* Mention that `hugo new` does not add `draft = true` when the user
  provides an archetype
* List short examples of TOML and YAML side by side
* Compact the Math template functions into a table
* Put some notes into a blockquote
2015-01-17 00:45:53 -07:00
Tatsushi Demachi
0d17ee7ed4 Add operator argument to where template function
It allows to use `where` template function like SQL `where` clause.
For example,

    {{ range where .Data.Pages "Type" "!=" "post" }}
        {{ .Content }}
    {{ end }}

Now these operators are implemented:

    =, ==, eq, !=, <>, ne, >=, ge, >, gt, <=, le, <, lt, in, not in

It also fixes `TestWhere` more readable
2015-01-04 12:15:17 +01:00
Austin Ziegler
ae9c25afc0 Implement apply.
- apply seq fn args…
2015-01-02 11:50:22 +01:00
Austin Ziegler
6033abe1e7 Add a chomp function.
- Mostly useful in pipelines.
2015-01-02 11:50:22 +01:00
Tatsushi Demachi
fa8ac87d5e Make 'where' template function accepts dot chaining key argument
'where' template function used to accept only each element's struct
field name, method name and map key name as its second argument. This
extends it to accept dot chaining key like 'Params.foo.bar' as the
argument. It evaluates sub elements of each array elements and checks it
matches the third argument value.

Typical use case would be for filtering Pages by user defined front
matter value. For example, to filter pages which have 'Params.foo.bar'
and its value is 'baz', it is used like

    {{ range where .Data.Pages "Params.foo.bar" "baz" }}
        {{ .Content }}
    {{ end }}

It ignores all leading and trailing dots so it can also be used with
".Params.foo.bar"
2014-12-29 12:53:41 +01:00
Derek Perkins
717f702e2f Added delimit & sort template functions, tests and docs 2014-12-18 22:28:12 -05:00
Austin Ziegler
fd33e5d202 Documentation for ref and relref.
- Rejigged the weight of the extras/ content for the new crossreferences
  page.
- Used the new {{</*…*/>}} format for documenting highlighting and to
  prevent a warning about the missing `fig` shortcode.
2014-12-18 22:18:37 -05:00
Anthony Fok
a6d3862b87 Docs: Minor copyediting/proofreading
- Correct some typos
- Add backticks and commas where necessary
- Use fenced code blocks specifying "bash" as the language
  to avoid weird highlighting
- Place commas outside of quotation marks surroundingn codes
  to avoid possible confusion
- Suggest users to use the discussion forum rather than the
  mailing list
2014-12-08 22:44:30 +01:00
bep
d616617292 Doc for markdownify
This small function feels important enough to maybe deserve more than these three lines, but this will have to do for now.

This assumes that #652 gets merged.
2014-11-24 23:18:18 -05:00
Will Stevens
1d4dde7ac3 added docs for 'intersect' and 'in' template functions 2014-10-15 12:30:10 -04:00
Alex Dunn
275e1c0d23 more examples and explanation of go templating
Emphasizing to people (like me) who aren't familiar with Go that just because something's not mentioned in the Hugo docs doesn't mean it's not possible
2014-09-11 17:22:08 -04:00
Daniel Fairhead
012a473e27 added "eq" function to docs. 2014-09-11 17:02:20 -04:00
Anthony Fok
5dd3eaabee More proofreading and minor revisions to Hugo docs
Among the various changes, most instances of

    {{ template "partials/FILE.html" . }}

were changed to

    {{ partial "FILE.html" . }}

Also, in main.go, change "2013" to "2013-14".
2014-09-08 11:41:10 -04:00