Giter VIP home page Giter VIP logo

Comments (7)

doowb avatar doowb commented on May 21, 2024

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

from assemble.

jonschlinkert avatar jonschlinkert commented on May 21, 2024

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.

from assemble.

jonschlinkert avatar jonschlinkert commented on May 21, 2024

moved to helper-lib

from assemble.

primozcigler avatar primozcigler commented on May 21, 2024

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.

from assemble.

doowb avatar doowb commented on May 21, 2024

@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>

from assemble.

jonschlinkert avatar jonschlinkert commented on May 21, 2024

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>

from assemble.

primozcigler avatar primozcigler commented on May 21, 2024

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

from assemble.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.