Dasix / grits-plugin-docs

A Grits plugin for generating documentation
Other
1 stars 1 forks source link

Conditional logic #43

Closed robwhite4 closed 8 years ago

robwhite4 commented 8 years ago

@vmadman ,

So, I'm having an issue that requires various scopes of report output depending on the intended audience of that report.

I'm wondering what the best possible solution to that concern would be. Currently, I have to maintain separate copies of a document in order to satisfy this requirement.

I wonder if it would be possible to create a {@sanitize /} helper to wrap content in that would remove it from html / pdf output based on some white-matter trigger, like sanitize: true.

If this seems like something that would be useful / possible, I wonder if we could then extend so we could pass items in via white-matter in order to create conditions for what will display and what will not.

Something like:

(from /weather/index.md)

---
layout: docs
title: The Weather
sanitize: when
- north
- east

---

# The Weather for Today

{@sanitize terms="north, east"} (<-- will in this case be hidden)
It is a good thing you aren't in the North or East, 'cause it 'bout to be cold and wet 'round those parts.
{/sanitize}

{@sanitize terms="south, west"} (<-- will in this case not be hidden)
It is a good thing you aren't in the South or West, 'cause it 'bout to be hot and dry 'round those parts.
{/sanitize}

I don't know how it might work, or even if this solution is a really dumb one. Just thought I'd put it here so we can discuss it at some point.

Rob

vmadman commented 8 years ago

Dust provides sufficient conditionals (via built-in helpers) to do what you wanna do..

---
hello: world
---
{@eq key=hello value="world"}
    Hello World
{:else}
    Hello Mars
{/eq}

See: http://www.dustjs.com/guides/dust-helpers/

robwhite4 commented 8 years ago

omg you're right! Haha. I totally forgot about the 'out-of-the-box' dust helpers.

Thanks :+1: