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

Process .puml files for nunjucks #1256

Open damithc opened 4 years ago

damithc commented 4 years ago

Current: nunjucks code works inside inline PlantUML diagrams but doesn't work in .puml file

Suggestion: Allow nunjucks code in .puml files as well.

ang-zeyu commented 4 years ago

I don't think it's a good idea; It's not very nunjucks like (in that content belonging to other files is only rendered via {% include %}) and can cause issues with users of nunjucks not expecting the .puml to be rendered.

Have you tried

<puml name="...">
{% include "....puml" %}
</puml>

?

damithc commented 4 years ago

Have you tried

<puml name="...">
{% include "....puml" %}
</puml>

?

Yes, that works (sans live preview, but that's not a major issue).

I don't think it's a good idea; It's not very nunjucks like (in that content belonging to other files is only rendered via {% include %}) and can cause issues with users of nunjucks not expecting the .puml to be rendered.

I was trying to use variables that are defined in the variables.md, not <include>. e.g.,

@startwbs
+ <b><color:red>100</color></b> marks
 + Individual Project (iP): <b><color:red>{{ marks_ip }}</color></b> marks
 + Team Project (tP): <b><color:red>{{ marks_tp }}</color></b> marks
@endwbs
ang-zeyu commented 4 years ago

I was trying to use variables that are defined in the variables.md, not .

ahh missed that out, hmm, I still think there's quite a bit of feature overlap with <include>s though, and I feel like we shouldn't be rendering files other than .md/mbdf/mbd

You could still achieve it with a normal .md/mbdf file with an inline puml inside; this would also allow you to use the <variable>s in <include>s feature

<include src="xx.md">
<variable name="marks_ip">...</variable>
...
</include>

xx.md

<puml name="...">
@startwbs
+ <b><color:red>100</color></b> marks
 + Individual Project (iP): <b><color:red>{{ marks_ip }}</color></b> marks
 + Team Project (tP): <b><color:red>{{ marks_tp }}</color></b> marks
@endwbs
</puml>

that said, it shouldn't be too difficult to render just site variables for .puml files as well, what do you think?

damithc commented 4 years ago

You could still achieve it with a normal .md/mbdf file with an inline puml inside; this would also allow you to use the <variable>s in <include>s feature

I think this is good enough. Just need to add this bit of info into the documentation.