An inline shortcode's name must end with `.inline`, all lowercase.
E.g.:
```bash
{{< time.inline >}}{{ now }}{{< /time.inline >}}
```
The above will print the current date and time.
Note that an inline shortcode's inner content is parsed and executed as a Go text template with the same context as a regular shortcode template.
This means that the current page can be accessed via `.Page.Title` etc. This also means that there are no concept of "nested inline shortcodes".
The same inline shortcode can be reused later in the same content file, with different params if needed, using the self-closing syntax:
```
{{< time.inline />}}
```
Fixes#4011
`*json.UnmarshalTypeError` and `*json.SyntaxError` has a byte `Offset`, so use that.
This commit also reworks/simplifies the errror line matching logic. This also makes the file reading unbuffered, but that should be fine in this error case.
See #5324
Before this commit, you would have to use page bundles to do image processing etc. in Hugo.
This commit adds
* A new `/assets` top-level project or theme dir (configurable via `assetDir`)
* A new template func, `resources.Get` which can be used to "get a resource" that can be further processed.
This means that you can now do this in your templates (or shortcodes):
```bash
{{ $sunset := (resources.Get "images/sunset.jpg").Fill "300x200" }}
```
This also adds a new `extended` build tag that enables powerful SCSS/SASS support with source maps. To compile this from source, you will also need a C compiler installed:
```
HUGO_BUILD_TAGS=extended mage install
```
Note that you can use output of the SCSS processing later in a non-SCSSS-enabled Hugo.
The `SCSS` processor is a _Resource transformation step_ and it can be chained with the many others in a pipeline:
```bash
{{ $css := resources.Get "styles.scss" | resources.ToCSS | resources.PostCSS | resources.Minify | resources.Fingerprint }}
<link rel="stylesheet" href="{{ $styles.RelPermalink }}" integrity="{{ $styles.Data.Digest }}" media="screen">
```
The transformation funcs above have aliases, so it can be shortened to:
```bash
{{ $css := resources.Get "styles.scss" | toCSS | postCSS | minify | fingerprint }}
<link rel="stylesheet" href="{{ $styles.RelPermalink }}" integrity="{{ $styles.Data.Digest }}" media="screen">
```
A quick tip would be to avoid the fingerprinting part, and possibly also the not-superfast `postCSS` when you're doing development, as it allows Hugo to be smarter about the rebuilding.
Documentation will follow, but have a look at the demo repo in https://github.com/bep/hugo-sass-test
New functions to create `Resource` objects:
* `resources.Get` (see above)
* `resources.FromString`: Create a Resource from a string.
New `Resource` transformation funcs:
* `resources.ToCSS`: Compile `SCSS` or `SASS` into `CSS`.
* `resources.PostCSS`: Process your CSS with PostCSS. Config file support (project or theme or passed as an option).
* `resources.Minify`: Currently supports `css`, `js`, `json`, `html`, `svg`, `xml`.
* `resources.Fingerprint`: Creates a fingerprinted version of the given Resource with Subresource Integrity..
* `resources.Concat`: Concatenates a list of Resource objects. Think of this as a poor man's bundler.
* `resources.ExecuteAsTemplate`: Parses and executes the given Resource and data context (e.g. .Site) as a Go template.
Fixes#4381Fixes#4903Fixes#4858
Recurse through result of yaml package parsing and change all
maps from map[interface{}]interface{} to map[string]interface{}
making them jsonable and sortable.
Fixes#2441, #4083
* Page without front matter now treated same as a page with empty front matter.
* Test cases added to cover this and repro issue #4320.
* Type safety of front matter code improved.
Fixes#4320
This commit removes the fragile front matter decoding, and takes the provided archetype file as-is and processes it as a template.
This also means that we no longer will attempt to fill in default values for `title` and `date`.
The upside is that it is now easy to create these values in a dynamic way:
```toml
+++
title = {{ .BaseFileName | title }}
date = {{ .Date }}
draft = true
+++
```
You can currently use all of Hugo's template funcs, but the data context is currently very shallow:
* `.Type` gives the archetype kind provided
* `.Name` gives the target file name without extension.
* `.Path` gives the target file name
* `.Date` gives the current time as RFC3339 formatted string
The above will probably be extended in #1629.
Fixes#452
Updates #1629
We still have go-toml as a transitive dependency, and it is the way to go eventually, but we care about speed, so let us wait that one out.
Note that the issue this fixes is about taxonomies, but I guess this is a general issue for sites with many pages that uses TOML as front matter.
```
benchmark old ns/op new ns/op delta
BenchmarkFrontmatterTags/TOML:1-4 23206 8543 -63.19%
BenchmarkFrontmatterTags/TOML:11-4 80117 18495 -76.92%
BenchmarkFrontmatterTags/TOML:21-4 140676 28727 -79.58%
benchmark old allocs new allocs delta
BenchmarkFrontmatterTags/TOML:1-4 173 60 -65.32%
BenchmarkFrontmatterTags/TOML:11-4 625 138 -77.92%
BenchmarkFrontmatterTags/TOML:21-4 1106 210 -81.01%
benchmark old bytes new bytes delta
BenchmarkFrontmatterTags/TOML:1-4 9231 2912 -68.45%
BenchmarkFrontmatterTags/TOML:11-4 19808 5184 -73.83%
BenchmarkFrontmatterTags/TOML:21-4 31200 7536 -75.85%
```
See #3541
Updates #3464
Difference between toml.Load(string(datum)) and
toml.LoadReader(bytes.NewReader(datum)):
benchmark old ns/op new ns/op delta
BenchmarkLoad-4 82068 78489 -4.36%
benchmark old allocs new allocs delta
BenchmarkLoad-4 494 493 -0.20%
benchmark old bytes new bytes delta
BenchmarkLoad-4 17009 16913 -0.56%
Lots of cleanups here:
- Refactor InterfaceToConfig and InterfaceToFrontMatter to use io.Writer.
- Simplify InterfaceToFrontMatter by wrapping InterfaceToConfig.
- Export FrontmatterType since we return it in DetectFrontMatter.
- Refactor removeTOMLIdentifier to avoid blindly replacing "+++".
- Update HandleJSONMetaData to return an empty map on nil input.
- Updates vendored goorgeous package and test for org-mode frontmatter.
- Add tests and godoc comments.
Coverage for parser package increased from 45.2% to 85.2%.
Useful if using or sharing files with users that use editors that
append a unicode byte order marker header (like Windows notepad).
This will still assume files are UTF-8 encoded.
Closes#2075