Closed ckennedy666 closed 2 years ago
I'm not at my computer right now, but why do you have a tilde before the closing brackets "~}}" ?
I'm not at my computer right now, but why do you have a tilde before the closing brackets "~}}" ?
To suppress white space generation at those points.
Where can I get hold of a TSV file (traveller star map) so that I can test your markdown template?
In a quick test, you should not have the parentheses around the "Stars" name immediately after match
The match function is better handled by a syntax like:
Stellar:
{{#each (match Stars "[OBAFGKM]\d\s\w+|D|BD|BH|NS|PSR" "regex: true") ~}}
- {{this}}
{{/each ~}}
Having looked at the match function, I don't think it does what we thought it does.
It will look for matches in the array of strings passed as the first parameter for any entries which match the second parameter.
What we need is a function that will break a string based on a regex.
I've just created 0.18.0 which adds a new function 'strsplit' which splits a single string into multiple parts.
The following seems to work with the new helper function:
Stellar: {{#each (strsplit Stars (toRegex "([OBAFGKM]\d)")) ~}}
{{#ifOdd @index }}
- {{/ifOdd}}{{this}}{{/each}}
(The separator is put into the output array as a separate element, and the first element is a blank string, thus the use of #ifOdd to put the dash on a newline before the star's main classification.
Hmm... Tried to update to the latest, even using BRAT, and I'm not getting the strsplit helper included. Also the version still identifies as 0.17 instead of 0.18.
Ah, I forgot to update several files with the new version number. I'll fix it
0.19.0 should be marked properly, and should have the strsplit helper available.
I'll test tonight. Thanks for all the work.
Working perfectly (once I adjusted my regex). Thanks so much!
I'm loading TSV data and when I attempt to use match from Handlebar-Helpers I get errors. What I'm trying to do is process a field into an array using a regexp then process the element of the array into a list using #each. I get nothing but errors when I try to use the following code:
The field Stars contains data like:
The regex is to unstring the multiple stars in the data field and put them on separate lines.