magynhard / curly-bracket-parser Goto Github PK
View Code? Open in Web Editor NEWSimple parser to replace variables inside templates/strings and files
License: MIT License
Simple parser to replace variables inside templates/strings and files
License: MIT License
Considering this package as a replacement of handlebars (cause it's heavy and dedicated on node envs requires fs.)
Yet I have concerns since my projects are ts based.
Whenever I have a string with multiple variables and there is one variable that is unresolved I currently get this error:
"There are unresolved variables in the given string: {{variable}}"
I would like an option to ignore this error and return the string with all the variables that are resolved and the ones that are not resolved keep as is or return as empty string.
I think it would be nice to add the possibility to allow depth in the provided data object.
For exemple {{resume.title}}
, {{figure.slider.description}}
could be replace with the content of passedData['resume']['title']
and passedData['figure']['slider']['description']
respectively.
For myself, I'm trying to parse a document with an object containing data at varying depth of an object tree.
Currently I have to either flatten my data object, or split the parsing of my page into 6 different steps. And I actually have to add another step on top of it, reading the whole document, because I need one data element multiple times accross the whole document. I can't do at the moment simply due to how the data is arranged.
This is the current exemple
(excerpt of exemple data)
(excerpt of exemple javascript)
(excerpt of exemple html)
With this enhancement, I could parse the whole document at once, in one command, without modifying how my data is stored.
I think it would be very useful in and of itself but would also probably open possibilities for loop filters, and other neat things down the road.
Thanks for building this library.
Whenever I have a variable that is undefined the library does not return anything. My application basically just freezes because it is waiting for a return.
I think it would be better to change undefined variables to a empty string or to return an error that it is not allowed to have a undefined variable.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.