MarkBind / markbind

MarkBind is a tool for generating content-heavy websites from source files in Markdown format
https://markbind.org/
MIT License
135 stars 124 forks source link

include: allow specifying tags #719

Open damithc opened 5 years ago

damithc commented 5 years ago

Suggestion: Allow specifying tags in include directives so that alternate content can be configured at the point of inclusion.

e.g., <include src="foo.md" var-tags="lang--java level--basic" />

ang-zeyu commented 4 years ago

How about supporting type="js" variables (essentially whatever nunjucks's {% set %} supports) instead?

<variable type="js">0</variable> -> try parsing as a number number <variable type="js">false/true</variable> -> if not try booleans finally <variable type="js">[ ... ] or { ... }</variable> -> parsed using json, evaluating to object / array

Or we could do away with the type=js and just "" or '' to indicate strings for better syntax standardisation (breaking change though, maybe slate this for v3.0)

Then just use {% if %}'s inside the included file to configure the content

damithc commented 4 years ago

@ang-zeyu this feature suggestion is tied to the existing tags feature which caters for varying content based on tags. We already support specifying tag filters (i.e., which content to include/exclude) in several places such as frontmatter and site.json. I'm suggesting we can also allow specifying those tags in the include tags i.e., the author is saying "include content of foo.md but exclude parts tagged as language--java"

ang-zeyu commented 4 years ago

ahh ok, makes sense. What do you think of the types of inline variables <variable> should support though? (currently being only strings)

damithc commented 4 years ago

ahh ok, makes sense. What do you think of the types of inline variables <variable> should support though? (currently being only strings)

Yes, it might come in handy. But might want to hold on for now. I haven't used the current variable feature enough to say string-only is a serious limitation. Note that MarkBind doesn't have a way to use other types of variables. So, non-string variables can only be used in nunjucks macros.