Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
271 views
in Technique[技术] by (71.8m points)

handlebars.js - Add tags to a list for text carousel

I would like to show the tags used in my Ghost blog in a text carousel. You can see a live example in my website, just below the title, in the description part.

I successfully adapted this code to my handlebar page, but I’m stuck with the {{tags}} or {{#get ‘tags’}} handlebars:

I would like to replace the static data-rotate=’[ “tag1”, “tag2.”, “tag3” ]’ part with the real list of tags.

<h1>Tags: 
  <span
     class="txt-rotate"
     data-period="2000"
     data-rotate='[ "tag1", "tag2.", "tag3" ]'></span>
</h1>

I tried many things, as this one:

<span class="txt-rotate" data-period="2000"
    data-rotate=[
        {{#get "tags" limit="all"}}
            {{#foreach tags}}
                "{{name}}"
                {{#unless @last}},{{/unless}}
            {{/foreach}}
        {{/get}}
     ]>
</span>

But it doesn't work. I think that I need to transform a string (tag1, tag2) in a list ["tag1", "tag2"], but I don't know how. Any idea?

Thanks for your help!

question from:https://stackoverflow.com/questions/65909649/add-tags-to-a-list-for-text-carousel

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...