Giter VIP home page Giter VIP logo

nsmarty's People

Contributors

stepofweb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nsmarty's Issues

capturing errors from templates

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);
   }
}

clearing cache

The clearCache() method somehow doesn't work, I'm refreshing the page, and the content doesn't change.

assignByRef

Is assignByRef supported?

Suppose we can assign to the tpl a Javascript Object.
Can we do this?

{$MyObj->myfunction("param1","param2")}

using config files

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...

async plugins and async/stream'n'pipe in general

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.

clear cache when server running

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?

util.pump is not a function

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)

Parse String as Template

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>

Not Working with Node 8

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.