helpers / handlebars-helpers

188 handlebars helpers in ~20 categories. Can be used with Assemble, Ghost, YUI, express.js etc.
http://assemble.io/helpers/
MIT License
2.22k stars 364 forks source link

String Filters For Output from YAML Not Working #276

Closed grayghostvisuals closed 7 years ago

grayghostvisuals commented 7 years ago

I have this line where I spit out some categories…

{{#category "client"}}
    <li>{{ data.tags }} <a href="#{{data.title}}">{{data.title}}</a></li>
{{/category}}

Issue I'm running into is the fact I cannot filter the output like so…

{{ capitalize data.tags }}

Here's the link to my current Gulp file https://github.com/grayghostvisuals/site/blob/development/gulpfile.js

doowb commented 7 years ago

@grayghostvisuals sorry for the delay...

What is {{data.tags}}? Will you log it out using {{log data.tags}} just before the <li> line. Then you can log out {{log (capitalize data.tags)}} to see what that returns.

grayghostvisuals commented 7 years ago

@doowb I have 2 sections on the same page both looping thru the same thing. Here they are in the order of appearance on my page and in the markup:

First Loop

{{#category "client"}}
    <li><a href="#{{lowercase data.title}}">{{data.title}}</a> : {{uppercase data.tags}}</li>
{{/category}}

Second Loop

{{#category "client"}}
<li id="{{lowercase data.title}}" class="ggv-datalist__item {{lowercase data.title}}">
    <a href="{{data.categories}}/{{lowercase data.title}}">
        <span class="ggv-datalist__item-data">{{uppercase data.tags}}</span>
    </a>
</li>
{{/category}}

The first and second loop's output is 100% correctly functioning, but only the second loop has the filter of "uppercase" applied using {{uppercase data.tags}}.

doowb commented 7 years ago

Will you post the resulting html snippets that are produced from rendering the templates?

Also... to see the values while the templates are rendering you can use the {{log}} helper:

{{#category "client"}}
<li id="{{lowercase data.title}}" class="ggv-datalist__item {{lowercase data.title}}">
    <a href="{{data.categories}}/{{lowercase data.title}}">
                {{log data.tags (uppercase data.tags)}}
        <span class="ggv-datalist__item-data">{{uppercase data.tags}}</span>
    </a>
</li>
{{/category}}

That will log the values to the console.

doowb commented 7 years ago

@grayghostvisuals I'm trying to reproduce the issue that you're having, but every place I add {{uppercase data.tags}} the rendered html has all uppercase characters there so I'm not sure where the issue is occurring without more information.

grayghostvisuals commented 7 years ago

@doowb Figured it out. Before I updated Assemble I was fixing it with CSS. Works as it should now. Thanks for checking.