I want to do something alone these lines:
var videos = {{.Split .Doc.media ","}};
where media
is a comma-separated string of names that should become the videos
array. I can’t seem to figure out a way to accomplish this. I’ve tried using a YAML list as well as a string.
I was able to do it with:
var videos = '{{js .Doc.media}}'.split(',');
But if anyone knows how I can do this with a YAML list, please chime in. I’d prefer not to do the split().
matt
(Matt Holt)
August 31, 2016, 10:27pm
3
What result was that giving you? (the first attempt) - I doubt it produces JavaScript code…
The first attempt produces nothing. Second attempt works, but I’d like to be able to use a YAML array.
matt
(Matt Holt)
September 5, 2016, 5:08am
6
It works.
Caddyfile:
localhost
markdown {
template tpl.html
}
index.md:
---
media: "foo,bar"
---
Testing!
tpl.html:
<html>
<body>
{{range .Split .Doc.media ","}}
{{.}}<br>
{{end}}
</body>
</html>
Output:
foo
bar
system
(system)
Closed
December 4, 2016, 5:08am
7
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.