ollym / parrot Goto Github PK
View Code? Open in Web Editor NEWA lightning fast and lightweight templating engine for Node.js
A lightning fast and lightweight templating engine for Node.js
I can't get Parrot working. First, simple examples (as in the Readme) give me the following error:
SyntaxError: Invalid flags supplied to RegExp constructor 'g,m'
Once I changed all of the RegExp constructors to use strings ("gm" or "gmi"), I got this error:
TypeError: Cannot call method 'runInNewContext' of undefined at Object.render (/Users/jacobevelyn/node_modules/parrot/index.js:165:9)
Seems like some big problems are going on here.
See ERB in the Ruby documentation:
ERB recognizes certain tags in the provided template and converts them based on the rules below:
<% Ruby code -- inline with output %> <%= Ruby expression -- replace with result %> <%# comment -- ignored -- useful in testing %> % a line of Ruby code -- treated as <% line %> (optional -- see ERB.new) %% replaced with % if first thing on a line and % processing is used <%% or %%> -- replace with <% or %> respectively
This also features some escaping for ERB tags.
The trim_mode
parameter is interesting, too:
If trim_mode is passed a String containing one or more of the following modifiers, ERB will adjust its code generation as listed:
% enables Ruby code processing for lines beginning with % <> omit newline for lines starting with <% and ending in %> > omit newline for lines ending in %>
Hey, Im LOVING this library and using it on my newest project.
It works if I do for example: <%=variable%>
If I do this:
<% for(var i = 0; i < 3; i++) { %>
It breaks with:
SyntaxError: Unexpected identifier
at Object.render (/node.js/node_modules/parrot/index.js:165:9)
at /node.js/sql.js:54:14
at [object Object]. (fs.js:107:5)
at [object Object].emit (events.js:61:17)
at afterRead (fs.js:878:12)
at wrapper (fs.js:245:17)
The used regular expressions are problematic and will easily break the VM. Here some points:
.+
) instead of a non-greedy one (.+?
). This will skip the end tag if another one follows, e.g. <%= var %> foo <%= bar %>
becomes print(var %> foo <%= bar);
I'm currently working on a commit, hopefully resolving all bugs. Pull request follows.
Also you might consider releasing a new version of parrot, since the 0.3.0 that can be downloaded via npm is outdated.
This could be easily implemented, we just need to convert the code to real JavaScript after we compiled the input using RegEx.
Since you have config.cache = config.cache || exports.config.cache;
, you can't set cache to 0, you have to set it to a negative to get a similar effect.
There's no way that I can tell to escape user input within the template.
I'm seeing this odd issue, hopefully someone can confirm it.
var data = "<%= foo(\"bar\") %>";
var view = {
foo: function(str){ return x(str) }
}
parrot.render(data, {sandbox:view})
var data = "<%= foo('bar') %>";
var view = {
foo: function(str){ return x(str) }
}
parrot.render(data, {sandbox:view})
B works when I encapsulate the function param 'bar' with single quotes instead of double quotes.
Can anyone else reproduce this?
Hey there,
i am currently working on a cli for a translation management system right within figma called Parrot: https://www.figma.com/community/plugin/1205803482754362456
The npm package name parrot is taken by this project tho... Since this project seem to be a bit outdated i was wondering if you would be willing to transfer the name?
Best regards
Martin
If one were to render a two user pages near-simultaneously with completely separate information in each sandbox, you will get repeated, bad data.
It's not the largest library in the world, this shouldn't be too hard
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.