Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handlebars helper: file name, file name with extension #32

Closed
jonschlinkert opened this issue Feb 2, 2013 · 7 comments
Closed

handlebars helper: file name, file name with extension #32

jonschlinkert opened this issue Feb 2, 2013 · 7 comments

Comments

@jonschlinkert
Copy link
Member

No description provided.

@doowb
Copy link
Member

doowb commented Feb 18, 2013

What does this mean? Is this something that would be better as being a default global variable available in the context?

@jonschlinkert
Copy link
Member Author

This would be probably two helpers which would enable you to add the file name and/or file extension to the page as a string. One for the name of the current file, {{filename}}, and probably one that grabs the extension of the current file {{fileext}}. However, I can't remember use case so this is unimportant for now. I'll leave it open for a bit, but we can close it if it goes another week or so without me remembering what problem this solved.

@jonschlinkert
Copy link
Member Author

moved to helper-lib

@primozcigler
Copy link

I know it is old, but I am struggling with a problem that this helper would solve: I want to build the HTML menu dynamically and have the YAML file with the key-value pairs, where key is the same as the filename of the HTML file, so with with a helper I could compare the current filename and the data and export the class="active" when they match.

@doowb
Copy link
Member

doowb commented Dec 29, 2013

@primozcigler we actually added isCurrentPage to all the pages in the pages collection, so you can do something like...

<ul>
{{#each pages}}
  <li class="{{#if isCurrentPage}}active{{/if}}">{{title}}</li>
{{/each}}
</ul>

@jonschlinkert
Copy link
Member Author

Or just get https://github.com/helpers/handlebars-helper-isActive (and follow the instructions on the README of that project), then you can do:

<ul>
  {{#each pages}}
  <li {{isActive}}>{{title}}</li>
  {{/each}}
</ul>

@primozcigler
Copy link

That's awesome, I will take a look, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants