Uh oh!
There was an error while loading. Please reload this page.
Implement page variable functionality - #627
Conversation
damithc
commented
Jan 23, 2019
should we call them constants instead?
|
We could, but aren't the global variables kind of like constants too, in that case? |
damithc
commented
Jan 24, 2019
At the moment, they are too. |
yamgent
commented
Jan 24, 2019
But if the users can do a |
acjh
commented
Jan 24, 2019
We may also consider implementing overriding the sub-sites' variables in future. |
damithc
commented
Jan 24, 2019
That's true. We have several types of variables each behaving in a different way; we should come up with a good terminology to differentiate them. |
jamos-tay
commented
Jan 25, 2019
Sure - maybe we should just leave it as variable for now then since that's how |
ff22bd5 to
c724d83Comparejamos-tay
commented
Jan 28, 2019
Implemented page variables + included variables, should be ready |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
jamos-tay
commented
Jan 29, 2019
Updated, page variables can now cascade into included files. Page variables are now treated exactly like included variables, global > outer > inner priority etc.. The only difference is how they're defined (span vs variable) |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
0c63d84 to
eafb330CompareUpdate documentation
jamos-tay
commented
Jan 31, 2019
Updated |
damithc
commented
Feb 4, 2019
Good work on this feature @jamos-tay (and @yamgent, @acjh). I've started using it and worked great so far. What do you guys think of allowing the reuse context to access page variables using the e.g., |
acjh
commented
Feb 4, 2019
Isn't that the syntax for fragments? |
Yes. a variable is like a hidden fragment, right? Of course name clashes is a concern but in that case we can follow the same rules as multiple segments with same ID? |
jamos-tay
commented
Feb 4, 2019
Hmm... I think that implementation might have a few unwanted implications. For example, if the reasoning is |
Accessing a variable value from the parent doesn't mean the variable is raised to the level of the parent. It's simply reading the value only. I was hoping to use variables as properties of the page. e.g., title, summary, level, difficulty etc. Similar to a public varaible of a Java object, it makes sense to be able to access properties of the object from outside. Of course, I can use |
jamos-tay
commented
Feb 8, 2019
Hmm okay, that seems reasonable It would have to be treated separately from a regular include, though |
damithc
commented
Feb 8, 2019
Moved the discussion to #682 |
What is the purpose of this pull request? (put "X" next to an item, remove the rest)
• [X] Enhancement to an existing feature
Fixes#575
What is the rationale for this request?
Extension of included variable functionality, allow users to specify local variables within the same page.
What changes did you make? (Give an overview)
Users can specify local variables with the
variablekey word:They can use it within the page like normal variables.
Is there anything you'd like reviewers to focus on?
Should variables cascade into includes? I'm thinking no, it can be confusing if the user is trying to trace where a variable came from and can't find it. If the user wishes for them to be used they can include it specifically:
All page variables are processed before any rendering is done, so users cannot change the value of variables mid page:
I don't think supporting this is a good idea since we won't be able to use nunjucks and would have to write our own parser. Users can use
{% set %}as an alternative. Currently a warning is shown if the user tries to reassign a variable.