Assign to javascript var in template

I want to do something alone these lines:

var videos = {{.Split ","}};

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}}'.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().

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.

It works.


markdown {
    template tpl.html

media: "foo,bar"



	{{range .Split ","}}



This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.