MarkBind / markbind

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

Variable override seems buggy #2519

Closed yiwen101 closed 2 months ago

yiwen101 commented 2 months ago

Please confirm that you have searched existing issues in the repo

Yes, I have searched the existing issues

Any related issues?

No response

Tell us about your environment

MacOs

MarkBind version

Current master

Describe the bug and the steps to reproduce it

in _markbind/variables.md:

<variable name="filename">variables.md</variable>

in index.md:

{% set filename = "index.md" %}
filename is {{ filename }}
{% set x = "index.md" %}
x is {{ x }}

Expected behavior

I expect to see: "file name is index.md x is index.md",

but I actually see "file name is variable.md x is index.md"

Anything else?

No response

damithc commented 2 months ago

@yiwen101 To facilitate reuse, an outsider should be able to override variables to customize the component to fit her needs (yes, this is the opposite of normal variable overriding). That way, the component can be reused without changing its code.

yiwen101 commented 2 months ago

@yiwen101 To facilitate reuse, an outsider should be able to override variables to customize the component to fit her needs (yes, this is the opposite of normal variable overriding). That way, the component can be reused without changing its code.

I see, thanks for the clarification. I just noticed that the documentation also specifies that "Global variables (_markbind/variables.md) will take precedence over any variables set via Nunjucks' tags (e.g. {% set %}).". This is quite counter intuitive.

I found another issue related to this. So sorry for posting this is duplicate issue.