You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, in some cases, the .Raw may contain a template include (e.g. {{ template "youtube" "someid" }} for easier YouTube embeds). Because I'm pulling this from the .Raw content, the template tag is never parsed, so the rendered excerpt on the pagination pages uses the literal {{ template ...}} syntax rather than having it rendered (like inner-template).
I tried adding an inner-template step after the template that creates the excerpt:
However, the markdown filter/template func in the excerpt template above escapes the " and results in the template string looking like {{ template "youtube" ...}} which results in the following error:
template: ad-hoc:156: unexpected "&" in template invocation
There's two ways I can see this getting fixed.
Move some of the logic of ProcessInnerTemplate into a template function so it can be called like `{{ .Raw | cut "" "\n\n" | render | markdown }} so that the inner template is rendered before processing as Markdown (and ultimately escaping quotes and other HTML entities).
Overwrite page.raw after making a call to the inner-template step in the config, so that ProcessInnerTemplate ends with:
The second option does work, but it feels a bit dirty/hacky because we don't know when/where inner-template might be used in the build step. So it might be better to implement it as a template function as described in the first option.
Thoughts?
The text was updated successfully, but these errors were encountered:
holic
added a commit
to holic/gostatic
that referenced
this issue
Jul 30, 2015
I'd say extracting inner-template is not anything special unlike (I decided in previous discussion, ha-ha) config is, so it would make sense to have it as a function (like markdown).
Continuing from #34 (comment)
In pagination, I'm using the
.Raw
content to extract an "excerpt" from each post:However, in some cases, the
.Raw
may contain a template include (e.g.{{ template "youtube" "someid" }}
for easier YouTube embeds). Because I'm pulling this from the.Raw
content, the template tag is never parsed, so the rendered excerpt on the pagination pages uses the literal{{ template ...}}
syntax rather than having it rendered (likeinner-template
).I tried adding an
inner-template
step after the template that creates the excerpt:However, the
markdown
filter/template func in the excerpt template above escapes the"
and results in the template string looking like{{ template "youtube" ...}}
which results in the following error:There's two ways I can see this getting fixed.
Move some of the logic of
ProcessInnerTemplate
into a template function so it can be called like `{{ .Raw | cut "" "\n\n" | render | markdown }} so that the inner template is rendered before processing as Markdown (and ultimately escaping quotes and other HTML entities).Overwrite
page.raw
after making a call to theinner-template
step in the config, so thatProcessInnerTemplate
ends with:The second option does work, but it feels a bit dirty/hacky because we don't know when/where
inner-template
might be used in the build step. So it might be better to implement it as a template function as described in the first option.Thoughts?
The text was updated successfully, but these errors were encountered: