Giter Site home page Giter Site logo

express-hogan.js's People

Contributors

dundee avatar dustinsenos avatar

Stargazers

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

express-hogan.js's Issues

error on preparePartials function with express 3

Hi, i've an issue with preparePartials

PROJECT_PATH/node_modules/express/lib/application.js:506
fn(err);
^
TypeError: object is not a function
at Function.app.render (PROJECT_PATH/pushserver/node_modules/express/lib/application.js:506:5)
at ServerResponse.res.render (PROJECT_PATH/DEV/pushserver/node_modules/express/lib/response.js:601:7)
at exports.index (PROJECT_PATH/pushserver/routes/dashboard.js:40:25)
at _.after (PROJECT_PATH/pushserver/node_modules/express-hogan.js/node_modules/underscore/underscore.js:609:38)
at expressHogan.preparePartials (PROJECT_PATH/DEV/pushserver/node_modules/express-hogan.js/lib/express-hogan.js:47:12)
at fs.readFile (fs.js:176:14)
at Object.oncomplete (fs.js:297:15)

my apps crash and no partials is loade... actually nothing is loaded :P

i need some help please :(

update this for express 3.0

Currently tj merged in hjs - which seems way worse then what you have here (doesn't seem to support partials, etc.).

Would be cool to update this plugin and get it merged instead

package name includes .js

I just installed this, using npm. When requiring your lib within nodejs, the package name appears to be "express-hogan.js", and that is how you have to require it (require('express-hogan.js')).

I'm not sure if this was intended or not, but based on your test application it doesn't look like it was. Just thought I'd mention this. I don't know how to fix this, because I've never submitted anything to npm before, otherwise I'd try to offer more assistance and perhaps a pull request.

preparePartials not working for multiple partials

In the preparePartials function, the readFile function should be called as a closure. Currently only the last partial is being loaded. Please see the code with the fix below.

    expressHogan.preparePartials = function(root, partials, func) {
            var sources = {};
            var ready = _.after(partials.length, func);
            for (var i in partials) {
                    (function(i){
                    fs.readFile(root + '/' + partials[i] + '.html', function(err, data) {
                            if (err) {
                                    console.log(err);
                                    return;
                            }
                            sources[partials[i]] = data.toString('utf8');
                            ready(sources);
                    })})(i);
            }
    };

app.dynamicHelpers()

Hello,

The variables defined in the dynamicHelpers are not available in the views. I tried applying the fix suggested in Medium/matador#28 and it worked. Below is the modified code.

      expressHogan.compile = function(source, options) {
            if (typeof source == 'string') {
                    return function(options) {
                            options.locals = options.locals || {};
                            options.partials = options.partials || {};

                            if (options.body) {
                                    options.locals.body = options.body;
                            }
                            for (var i in options.app.dynamicViewHelpers) {
                                    options.locals[i] = options[i];
                            }

                            var template = hogan.compile(source);

                            for (var i in options.partials) {
                                    if (typeof options.partials[i].r == 'function') continue;
                                    options.partials[i] = hogan.compile(options.partials[i]);
                            }

                            return template.render(options.locals, options.partials);
                    };
            } else {
                    return source;
            }
    };

need docs about how to use partials

I have my index.mustache including a partial tag {{> form}} and the partial is put under the same path.

However, the partial doesn't load at all.

There is not enough doc in the testapp.js to indicate correct usage of partials, would you help in this case?

I use the following code to render the template:

app.get('/', function (req, res) {
  res.render('home');
})

Rendering partials aren't working for me

In my layout.html file (app/views/layout.html), I've got the following:

{{> _header }}

which I'd like to basically render the partial from app/views/partials/_header.html. That partials' never being loaded when I access the page, though. This worked great in Matador, but isn't working with express.

Any ideas on what else I'd need to do?

Thanks!

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.