Skip to content

Conversation

@asolis
Copy link

@asolis asolis commented Jul 23, 2016

It adds the possibility of formatting the string in place using sprintf syntax. Otherwise, a function needs to be created or the json data have to be formatted before hand.

The sprintf function was modified to use the same syntax of json2html for back compatibility,
e.g., ${name.0.subname.1}.

As a consecuence the tokenizer function has been removed, the sprintf function does the necessary steps for parsing the values.

example:
var transform = {"<>":"i", "html":"${name} ${lastname} ${id}03d ${salary}.2f"}

John Smith 001 5000.50

asolis added 4 commits July 23, 2016 04:39
sprintf("${1} ${2} ${0}", [ 7, 9, 11])

will return

"9 11 7"

It's also possible to concatenate index access, e.g., ${3.0.1} will take the value at elem[3][0][1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant