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

Templates added using custom_routes.templates don't show up in /api/get_templates_listing #849

Closed
Schamper opened this issue Jan 23, 2014 · 3 comments

Comments

@Schamper
Copy link
Contributor

#846 (comment)

This is the reason why pages added from plugins can't be ajaxified.

Once this has been fixed, a plugin will be able to add an ajaxified page using the filter:server.create_routes hook like so:

fs.readFile(path.resolve(__dirname, './partials/shoutbox.tpl'), function (err, tpl) {
    custom_routes.routes.push({
        route: constants.global.route,
        method: "get",
        options: function(req, res, callback) {
            callback({
                req: req,
                res: res,
                content: '<script>templates.ready(function(){ajaxify.go("' + constants.global.route + '", null, "' + "shoutbox" + '", true);});</script>'
            });
        }
    });

    custom_routes.api.push({
        route: constants.global.route,
        method: "get",
        callback: function(req, res, callback) {
            callback({});
        }
    });

    custom_routes.templates.push({
        "template": "shoutbox.tpl",
        "content": tpl
    });

    callback(null, custom_routes);
});
@julianlam
Copy link
Member

As usual, PR please 😄 (If there already is one, link to it and close this issue 👍 )

@Schamper
Copy link
Contributor Author

I don't know how you guys would prefer to have this done, but I'll give it a go and see if you guys agree.

@psychobunny
Copy link
Contributor

Thanks again @MrWaffle, works perfectably.

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

No branches or pull requests

3 participants