Skip to content

variable and if_variable tag clarifications #112

@wion

Description

@wion

I can't remember if I ever really knew how to use variables, or I just forgot, but I find them a little confusing now and the docs don't help at all. Maybe I'll try to improve the variable and if_variable docs, but first I have to understand them. The usual game. So following is what I understand, or think I understand, and what I don't understand at all. Please someone put me right.

variable

Can be used as a container or single tag.

It has two attributes: name="" and attribute="".

The name attribute seems straightforward enough. In order to use a variable at all (let alone assign a value to it), it must have a name.

So let's say we want a variable named 'string', and we want to assign a value to that variable equaling 'This is my string'. To do this as a container tag, it would be:

<txp:varible name="string">
This is my string.
</txp:variable>

How would we use that variable now? I don't know.

Do assign the same value as a single tag:

<txp:varible name="string" value="This is my string." />

Again, how would we use that? I don't know.

But I do know that some version of the variable must be put above where the value needs to be output. Example one in the variable doc seems to try to explain that idea, but not very well. The example seems like a lot of needless code and doesn't elucidate why the sole instance of the variable tag is at the bottom of it. Beats me.

And apparently you can also do this?

  • <txp:variable name='string' value="" />
  • <txp:variable name='string' value="0" />
  • <txp:variable name='string' value="1" />

But I have no clue what those mean exactly, or why you would use one over the other, and the aforementioned doc doesn't mention any of them in the attributes section, nor any examples given.

So, you can see where some deficiencies are for the those like me who need the detail.

if_variable

Jumping ahead to the if_variable tag. Presumably once you have a global variable set to one's liking, you can then call the assigned value in a conditional way, if needed:

<txp:if_variable name="string">
  <em><txp:variable name="string" />.</em> It's doing its thing.
</txp:if_varible>

Which could also be written using the new tag structure syntax, as:

<if::variable name="string">
  <em><txp:variable name="string" /></em> It's doing its thing.
</if::varible>

Either way, it would output as:

'This is my string. It's doing its thing.'

If someone will help me iron out the kinks in all this, I will commit to augmenting the docs with what I learn. Other pea brains like me should appreciate it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions