This feature may be overlooked when you read the release notes, so I’m double posting a little:
I know this will be useful for many.
This feature may be overlooked when you read the release notes, so I’m double posting a little:
I know this will be useful for many.
It is indeed very nice! But I didn’t understand the Ordinal
context’s field:
That’s it.
And I don’t understand the Position attribute. How would you use it ?
For now I get all sorts of errors that I didn’t get when using codeblock. See the following:
{{ $class := .Attributes.class }}
{{ $cite := .Page.RenderString .Attributes.cite }}
<figure {{with .Attributes.id}}id="{{.}}" {{end}} {{with $class}}class="{{.}}"{{end}}>{{with $title}}<figcaption>{{.}}</figcaption>{{end}}
<blockquote {{if in $cite "]("}}cite="{{strings.TrimSuffix ")" (index (last 1 (split $cite "](")) 0)}}"{{end}}>{{ .Text|.Page.RenderString (dict "display" "block") }}</blockquote>
<cite>{{with $cite}}{{.}}{{end}}{{with $author}} — {{.}}{{end}}</cite>
</figure>
it raises
ERROR render of “page” failed: “/home/drm/NNSITE/layouts/_default/baseof.html:27:4”: execute of template failed: template: _default/single.html:27:4: executing “specific-content” at <.Content>: error calling Content: “/home/drm/NNSITE/content/docs/ecotech.md:29:3”: “/home/drm/NNSITE/layouts/_default/_markup/render-blockquote.html:8:121”: execute of template failed: template: _default/_markup/render-blockquote.html:8:121: executing “_default/_markup/render-blockquote.html” at <$.Page.RenderString>: error calling RenderString: text is already rendered, repeating it may cause infinite recursion
You should (or so say I) only use it for error logging, mainly because it’s relatively slow to compute.
See this example:
It’s very useful for custom validation, as it will log the filename and position (line/col number) where the blockquote is; if you use an editor like VS code with built-in terminal, you can just command click on the position and it will take you there.
$.Page.RenderString>: error calling RenderString: text is already rendered
The Text
attribute in a blockquote render hook is HTML, and it does not make sense to render it again (it was a common cause of infinite recursion before we added the validation you see above).
Codeblocks are different; the .Inner
is the raw text, so to speak, which may make sense to pass to RenderString (but more common is to highlight it).
Ahhh… Makes sense. Great addition !