Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native express.js support #384

Closed
noel-schenk opened this issue Sep 18, 2019 · 9 comments
Closed

Native express.js support #384

noel-schenk opened this issue Sep 18, 2019 · 9 comments

Comments

@noel-schenk
Copy link
Contributor

noel-schenk commented Sep 18, 2019

Just took a quick look at how to implement twing into express.js

https://github.com/tj/consolidate.js/blob/master/lib/consolidate.js

and

adding twing (and linking) to the following page so more people start using it.
https://github.com/expressjs/expressjs.com/blob/gh-pages/en/resources/template-engines.md

/**
 * Twing support.
 */

exports.twing = fromStringRenderer('twing');

/**
 * Twing string support.
 */

exports.twing.render = function(str, options, cb) {
  return promisify(cb, function(cb) {
    var engine = requires.twing || (requires.twing = require('twing'));
    try {
        let tmpl = new engine.TwingEnvironment(new engine.TwingLoaderArray({
            'tmp': str,
        })).render('tmp', options);
        cb(null, tmpl);
    } catch (err) {
      cb(err);
    }
  });
};

I have to get some sleep. Maybe you can take a glimpse @ericmorand or I will try it tomorrow again.

@ericmorand
Copy link
Member

Would be amazing if you can take care of that - especially have Twing referenced on expressjs page. I'm not using express at all so I'm very appropriate to look at it.

@ericmorand
Copy link
Member

Actually, I proposed the link to Twing there:

expressjs/expressjs.com#1068

@DerekRoth
Copy link

Yep also interested. I’ll be using express and twing in an upcoming project.

@noel-schenk
Copy link
Contributor Author

Testing it rn. Will let you know once it's published.

@noel-schenk
Copy link
Contributor Author

tj/consolidate.js#327
Pull request is done. Have to wait for it to merge into the master. Then I can add it to the readme's.

@noel-schenk
Copy link
Contributor Author

noel-schenk commented Sep 19, 2019

@ericmorand any idea how we can keep this dependency (package.json) up to date?
https://github.com/tj/consolidate.js/pull/327/files#diff-b9cfc7f2cdf78a7f4b91a753d10865a2

@noel-schenk
Copy link
Contributor Author

Allows any packages from and up version 2.3.5
tj/consolidate.js@032cce1
Have to keep an eye on this.

@ericmorand
Copy link
Member

Isn't 2.3.5 enough? Is there a difference between this and >=2.3.5?

Anyway, thanks for your commitment on this. Couldn't have done it myself.

@noel-schenk
Copy link
Contributor Author

It allows all version newer than 2.3.5 and doesent require the exact version 2.3.5 otherwise this has to be updated all the time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants