Commit graph

58 commits

Author SHA1 Message Date
bep
103ea842f8 Fix errors reported by Go Vet 2015-03-06 15:25:19 +01:00
bep
6e1b0e0c00 Apply gofmt -s 2015-03-05 23:57:38 +01:00
bep
f0c8585b50 Use $.Paginator in template
Since there will only be one paginator per page, this can get rid of some scoping confusion.
2015-02-19 11:36:09 +01:00
René Jochum
d2e022f2a7 Suppress errors for symbolic links witch point to a file. 2015-02-17 19:18:28 -08:00
Cyrill Schumacher
076b618ff2 GetJson and GetCsv have now variadic URL parts so that you can submit pre or post parts of an URL. The parts will be joined to the final URL. 2015-02-17 12:14:39 -05:00
Cyrill Schumacher
10c2b41b85 Add --ignoreCache CLI flag with description "Ignores the
cache directory for reading but still writes to it" as @spf13
suggested.
2015-02-17 12:14:39 -05:00
Cyrill Schumacher
c168666b6d Adding getJson and getCsv to funcMap 2015-02-17 12:14:39 -05:00
Cyrill Schumacher
5e2d3d2e10 Merge to stay up to date with current dev
Feature: GetJson and GetJson in short codes or other layout files.
For more details please see: http://cyrillschumacher.com/2014/12/21/dynamic-pages-with-gohugo.io/
2015-02-17 12:14:39 -05:00
bep
13d9009406 Use .Site.Params.description as fallback for social partials 2015-02-01 19:56:21 +01:00
Anthony Fok
c50780930e Print template parsing errors to aid troubleshooting
Added a new Template.PrintErrors() function call,
used in hugolib/site.go#Process() so it does not clutter
up `go test -v ./...` results.

Special thanks to @tatsushid for mapping out the call trace
which makes it a lot easier to find the appropriate places
to place the Template.PrintErrors() call.

Fixes #316
2015-01-31 23:27:50 +01:00
bep
420c9e4d3d Add writable context to Node
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-31 22:01:30 +01:00
spf13
e1e6aaed2f Merge branch 'master' of github.com:spf13/hugo 2015-01-31 01:04:28 -05:00
bep
4a9436c116 Some more .Date.IsZero checks in internal templates 2015-01-30 22:05:03 +01:00
bep
230e7c02c5 Remove _default prefix from SEO templates 2015-01-30 21:58:18 +01:00
Anthony Fok
3d60955e17 Use .Date.IsZero to skip unset date in embedded templates
Use `{{ if not .Date.IsZero }}` to print dates only when they are
defined.  This is to avoid things like

    <lastBuildDate>Mon, 01 Jan 0001 00:00:00 +0000</lastBuildDate>

and

    <lastmod>0001-01-01T00:00:00+00:00</lastmod>

showing up in index.xml (RSS) and sitemap.xml.

Pipe dates with ±hh:mm time zone through `safeHtml`
to prevent the `+` sign from turning into `&#43;`.

Also make some shuffling to avoid blank lines in the output.
2015-01-30 21:04:06 +01:00
spf13
5441fc5dfc template render with BBP 2015-01-30 11:25:54 -08:00
bep
c0fbe61484 Add Bootstrap-compatible pagination.html
See #750
2015-01-26 13:34:12 +01:00
bep
020c0b863f Revert "Quick-and-dirty way to print details of template errors"
This reverts commit 42b33102cf.
2015-01-22 11:14:04 +01: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
edcdb6f49c Fix two errors in two internal templates
* template: _internal/_default/opengraph.html:39: unexpected EOF
 * template: _internal/_default/schema.html:15: unexpected {{end}}

Also change the DateTime inside these templates to ISO 8601 format,
and skip <meta itemprop="datePublished"> if `publishdate` is not set.

Perhaps it would be a good idea to expose `func (Time) IsZero`
to our templates?  :-)
2015-01-20 15:39:43 -07:00
bep
d897b1e8a7 Add missing assertion to trim-test 2015-01-20 22:31:05 +01:00
bep
1b91fec0ac Add tests for IsSet 2015-01-20 17:15:12 +01:00
bep
ee34a840bc Add test binaries to .gitignore 2015-01-20 16:49:28 +01:00
bep
f77f2a9b40 Refactor TestGt to also include Lt, Ge, Le, Eq and Ne 2015-01-20 16:38:23 +01:00
bep
f470cf9590 Add tests for Apply 2015-01-20 14:24:43 +01:00
bep
3f0f186b91 Add inline doc for Apply 2015-01-20 13:31:02 +01:00
bep
eabe8e1a98 Rename ignoreDotFile to isDotFile (which is what it is) 2015-01-20 13:21:50 +01:00
bep
077d726b51 Replace regexp based Chomp with builtin TrimRight 2015-01-20 12:41:08 +01:00
bep
99aee30410 Add tests for Replace 2015-01-20 12:30:49 +01:00
bep
26856c3b75 Add tests for Trim 2015-01-20 12:23:27 +01:00
bep
a6bf6f52ce Add tests for Chomp 2015-01-20 12:07:49 +01:00
Anthony Fok
42b33102cf Quick-and-dirty way to print details of template errors
See Issue #316.
2015-01-20 02:23:28 -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
Tatsushi Demachi
f5946ea3dd Add SafeHtmlAttr, SafeCSS template function
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
2015-01-19 19:47:37 -07:00
bep
783c76b86e Make RSS dates valid
See #789
2015-01-19 10:04:57 +01:00
bep
4f4015d751 Make all the params to Replace an interface{} 2015-01-18 15:16:48 +01:00
Tom Helmer Hansen
e08cabadb6 Rewrite first argument to interface{} 2015-01-18 14:54:26 +01:00
Tom Helmer Hansen
871e811339 Add trim and replace template functions 2015-01-18 14:54:26 +01:00
Anthony Fok
9150a98f3e Replace if with with in embedded rss.xml
... resulting in a slightly more compact template.
2015-01-14 21:05:13 -07:00
Anthony Fok
700c2b8f22 Trivial fixes to get RSS 2.0 feeds to validate.
RSS 2.0 requires the email be listed in `<author>`,
and `UTC` as a timezone is not accepted, but `UT` or `GMT` are.

See #789 for more information.  Thanks to @snej for the report!
2015-01-12 22:24:37 -07:00
Tatsushi Demachi
d12f6cd775 Fix echoParam template function to accept string key name
This changes `echoParam` template function behavior to accept not only
an array or a slice and its index pair but also a map and its key pair.

This also changes the function that float and uint values are treated as
a valid result type of it.

Fix #771
2015-01-08 02:32:17 +01: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
Austin Ziegler
14e93de8a1 Initialize funcMap in an init function. 2015-01-02 11:50:22 +01:00
Austin Ziegler
6a98d269b5 Hygiene: Reduce copy-pasted code. 2015-01-02 11:50:22 +01:00
Tatsushi Demachi
975f4cf126 Refactor tpl codes
- Use indirect function instead of the same code copies
- Fix missing arguments of some test codes
2014-12-29 15:47:50 +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
bep
fbf8bcacc4 Add configurable support for angled quotes
The flag `HTML_SMARTYPANTS_ANGLED_QUOTES` was added to Blackfriday on Black Friday. This configures rendering of double quotes as angled left and right quotes (&laquo;
&raquo;).

Typical use cases would be either or, or combined, but never in the same
document. As an example would be a person from Norway; he has a blog in both
English and Norwegian (his native tongue); he would then configure Blackfriday
to use angled quotes for the Norwegian section, but keep them as reqular
double quotes for the English.

This commit adds configuration support for this new flag, configuration that can be set in the site configuration, but overridden in page front matter.

Fixes #605
2014-12-26 14:31:55 +01:00
Derek Perkins
717f702e2f Added delimit & sort template functions, tests and docs 2014-12-18 22:28:12 -05:00