Dynamic parameters #23
-
|
Hi, In documentation, it seems that all examples have static list of paramters. For instance with @for: https://github.com/verhas/jamal#for
Is it possible to not have fixed values (a, b, c, d) but, read those values from another file ? Each line would be given as parameter ?
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
I like that you wrote: "it seems that all examples have static list..." I do because they are not. They may seem, but in Jamal, nothing is static. Anything can be the result of a macro evaluation. So if you have a file and want to have a
How should you do that? Let's get it one by one. The It will use the words as elements and generate the itemized list of the animals. Note that empty lines are just like regular lines. If you want to skip the blank lines, you can also use the To get the content of a file, you should use the macro Note that using It is often only the list of values that is the part to be evaluated, but the content repeated many times must not. Therefore, the second part must be protected from an evaluation using the The situation that the value list IS to be evaluated but the repeated text is not is so frequent that the But at the moment, it does not work due to a bug that I will fix in the next release. (In git you can see the commit with the fix.) The last thing is that you want to use something else instead of |
Beta Was this translation helpful? Give feedback.
I like that you wrote:
"it seems that all examples have static list..."
I do because they are not. They may seem, but in Jamal, nothing is static. Anything can be the result of a macro evaluation. So if you have a file and want to have a
forto iterate through all the lines, you need two things, plus an optional third:Specify that the value separator is a new line
Somehow, get the lines between the opening
(and closing)strings.Use something else other than
(and)as opening and closing strings when the)character may be present in the file.How should you do that? Let's get it one by one.
The
formacro has an option calledseparator. For example, the following code: