stepofweb / nsmarty Goto Github PK
View Code? Open in Web Editor NEWNode.js Smarty Template Engine
License: MIT License
Node.js Smarty Template Engine
License: MIT License
Hey, I have been trying to use this for an already developed project and it does not work with my local setup of node 8 but the production server is in node 4.6 and it is working good for that.
Can anybody tell me when will it update for node 4.6 or higher?
How to use for express?
please help.
I tried to execute the demo.zip on the latest node version, and I got this error:
util.pump(stream, res); // take place of _display() from PHP Smarty.
^
TypeError: util.pump is not a function
at Server.<anonymous> (C:\Users\macraft\Desktop\nsmarty\app.js:35:14)
at emitTwo (events.js:125:13)
at Server.emit (events.js:213:7)
at parserOnIncoming (_http_server.js:602:12)
at HTTPParser.parserOnHeadersComplete (_http_common.js:116:23)
Hi,
Thank you for this awesome porting Smarty, your work is amazing.
My question is: I change the TPL when the server is running, do I have to restart the server for the changes to take effect?
Is there a way to use a string as a template and render it to another string? I'm looking for something like this:
var s = nsmarty.compileText("tpl", "<p>Some {$text}</p>");
nsmarty.assign(s, {text:"Thing"});
var fin = nsmarty.render(s);
console.log(fin);
Where the log would read
<p>Some Thing</p>
Is assignByRef supported?
Suppose we can assign to the tpl a Javascript Object.
Can we do this?
{$MyObj->myfunction("param1","param2")}
hi there,
it is really cool, that you can use smarty for node. Till now it is really working quite good. But i have a small problem: the config file isnt working for me.
I searched for it in the code and documentation. But I could find only the {config_load} setting and a pregmatch for {#TEXT#}
but: how do i set the right filepath?
do i have to rewrite the code for that? I think so...
The clearCache() method somehow doesn't work, I'm refreshing the page, and the content doesn't change.
I have template https://gist.githubusercontent.com/indapublic/a9ae39b72cfac8643a1b/raw/18c1b808648391885a4f804edf0439b39db07cac/gistfile1.txt
and nodejs script https://gist.githubusercontent.com/indapublic/e4331f207fab836ca02c/raw/ee772f302b1ed882f38bd6946a79cd078cd1d83e/gistfile1.txt
Why I receive same template if I change "name" variable in nsmarty?
Hallo,
first of all: Awesome! Finally a port of Smarty for node. Thank you.
I have some questions:
Lets say i have this:
var tpl = nsmarty.assign('test.tpl', $arr)
tpl.on('data', function(chunk) {
})
Is chunk
really a small chunk, or is it always the rendered template as a whole? Respective: Is the data-event fired more than once, or does it fire only once?
And what about async plugins? Are they supported? And if they are, is the output of the plugin buffered and emited as a whole, or is the output small chunks too?
To break the above down into one question: Does NSmarty support asynchronous programming style and the stream-api of nodejs to the fullest?
Regards, Oliver.
I use the code:
var stream = nsmarty.assign(template, data);
util.pump(stream, req.res);
Since nsmarty uses asynchronous calls, it is impossible to capture any kinds of errors. Everything nsmarty (or the libraries it uses) throws lands in uncaughtExeption event handler on the process.
The sideeffect is that in case of a template error (unclosed block, syntax error, whatever), the connection from the browser is pending forever (until the socket timesout) and it is impossible to send an error message.
A very helpfull thing would be to add method accepting a standard callback, like:
nsmarty.fetch(mytemplate, data, function (err, result) {
if (err) {
res.end(someErrorPage());
} else {
res.end(result);
}
}
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.