Open damithc opened 5 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
@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
"
ahh ok, makes sense. What do you think of the types of inline variables <variable>
should support though? (currently being only strings)
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.
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" />