How to use the ejs.EjsView function in ejs

To help you get started, we’ve selected a few ejs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nrstott / bogart / lib / bogart / plugin / ejs / ejs_layout_renderer.js View on Github external
this.render = function(template, model, options) {
        options = options || {};
		model = model || {};

        var self = this;
        var out;

        var contentHolders = {};
        var viewModel = new EjsView(model);

        var templateLocals = {
            script_tag: function(script) {
                return viewModel.start_tag_for("script", { src: "/js/" + script + ".js", type: "text/javascript" }) +
                       viewModel.tag_end("script");
            },
            stylesheet_tag: function(stylesheet, htmlOptions) {
                var opts = { href: "/css/" + stylesheet + ".css", rel: "stylesheet", media: "screen" };
                util.update(opts, htmlOptions);
                return viewModel.start_tag_for("link", opts) + viewModel.tag_end("link");
            },
            content_for: function(namespace, callback) {
                if (!(callback instanceof Function))
                    throw new Error("content_for requires a function as its second argument");

                log.debug("content for " + namespace);
github nrstott / bogart / lib / bogart-ejs.js View on Github external
this.render = function(template, model, options) {
        options = options || {};
		model = model || {};

        var self = this;
        var out;

        var contentHolders = {};
        var viewModel = new EjsView(model);

        var templateLocals = {
            script_tag: function(script) {
                return viewModel.start_tag_for("script", { src: "/js/" + script + ".js", type: "text/javascript" }) + 
                       viewModel.tag_end("script");
            },
            stylesheet_tag: function(stylesheet, htmlOptions) {
                var opts = { href: "/css/" + stylesheet + ".css", rel: "stylesheet", media: "screen" };
                util.update(opts, htmlOptions);
                return viewModel.start_tag_for("link", opts) + viewModel.tag_end("link");
            },
            content_for: function(namespace, callback) {
                if (!(callback instanceof Function))
                    throw new Error("content_for requires a function as its second argument");

                print("content for " + namespace);