Comments (6)
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.
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.
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.
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.
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.
Clever solution. Thanks for posting this!
from grunt-bake.
Related Issues (20)
- Version for gulp HOT 1
- When in '_section', use properties outside this '_section' HOT 11
- Evaluate content inside of _section HOT 1
- Add variable for linking to originating file when using _bake-attribute HOT 2
- Integration of default transforms HOT 1
- Pass arrays/objects as inline attributes HOT 9
- Can't access properties in _section HOT 1
- bake-escape feature request HOT 20
- JSON file or CSV convert to multiple HTML files HOT 9
- Simple bake test HOT 1
- foreach loop to build multiple files per object HOT 1
- Unset variables are rendered as "undefined" HOT 3
- Placeholder Default HOT 5
- Assign/use variable in same file HOT 1
- Builtin placeholders HOT 2
- How to convert a folder with bake ? HOT 2
- Generate Bake with grunt.config.get HOT 2
- Bake one HTML file / JSON section in one go HOT 5
- Iteration over objects in _foreach HOT 6
- Can I read from package.json? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grunt-bake.