Giter Club home page Giter Club logo

Comments (6)

 avatar commented on August 11, 2024 1

I found a way to add a class="active" to a nav using the _if feature. It's a bit dirty, but it only requires you passing in a variable to test with bake-start and bake-end. Just be careful with the spacing if you have other classes in that same tag.

In includes/nav.html:

<div class="nav">
  <a href="index.html" class="<!--(bake-start _if="index")-->active<!--(bake-end)-->">Home</a>
  <a href="page2.html" class="<!--(bake-start _if="page2")-->active<!--(bake-end)-->">Page 1</a>
  <a href="page3.html" class="<!--(bake-start _if="page3")-->active<!--(bake-end)-->">Page 2</a>
  <a href="page4.html"  class="last <!--(bake-start _if="page4")--> active<!--(bake-end)-->">Page 3</a>
</div>

In index.html:

<!--(bake /src/includes/nav.html index="true")-->

For page2.html:

<!--(bake /src/includes/nav.html page2="true")-->

from grunt-bake.

roboshoes avatar roboshoes commented on August 11, 2024

I'm glad you can use it. I always try to enhance it's feature set while keeping it slim. I've come to around to the need for simple control elements as well. Still debating with myself on how to do it exactly. I'll post what I can come up with.

from grunt-bake.

roboshoes avatar roboshoes commented on August 11, 2024

Ok, this took way to long but i finally completed and pushed it. If Statement

<!--(bake some/influde.html _if="value.in.json")-->

If the value in the _if tag can't be found in the content.json or equals to false the include will be disregarded.

@jonlay maybe you can give it a spin and tell me what you think. (Sorry for the delay - office hours didn't leave much room for grunt-bake) 😌

Version 0.0.10

from grunt-bake.

hanno-jonlay avatar hanno-jonlay commented on August 11, 2024

Awesome, man! I've got the same sort of killer work hours, but I'm using bake on a few active projects at the moment, so I should be able to roll it out and give it a good testing next week!

from grunt-bake.

hanno-jonlay avatar hanno-jonlay commented on August 11, 2024

Whoah, I posted that 20 days ago - sorry dude.

But it does seem to work, as you obviously know! It's slightly different from what I actually envisaged, so I haven't actually found a proper use for it yet, beyond testing whether it actually works, but I'm sure it'll be handy regardless. I still haven't found a way to add a class="active" to a nav include, though 😆

from grunt-bake.

roboshoes avatar roboshoes commented on August 11, 2024

Clever solution. Thanks for posting this!

from grunt-bake.

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.