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

pluginifyjs does not parse EJS correctly #66

Closed
reykjavikingur opened this issue Feb 16, 2012 · 6 comments
Closed

pluginifyjs does not parse EJS correctly #66

reykjavikingur opened this issue Feb 16, 2012 · 6 comments

Comments

@reykjavikingur
Copy link

I am using EJS templates in an app, but when I run pluginifyjs on it, the resulting JS file has the EJS code concatenated directly into it. Trying to load this file in a browser throws an error: "Illegal XML character '<%'". The pluginifyjs script should parse EJS code into regular JS before inserting into the final JS output, so that it is possible to embed EJS files in applications.

@lastzero
Copy link

As far as I remember, it is a known limitation of pluginify that it can not include views. This will be "fixed" with a future release.

@roelmonnens
Copy link

This would be nice to have!

@juristr
Copy link

juristr commented Jul 16, 2012

Is there no fix for this so far??

@ghost ghost assigned moschel Jul 16, 2012
@jebaird
Copy link

jebaird commented Jan 15, 2013

Depending on which version of steal you have you can add the following lines to package views with in pluginfied scripts.

steal/build/pluginify/pluginify.js

in this method
s.build.pluginify.content = function(steal, param, opener){

add / replace

if( /\.ejs/.test(steal.rootSrc ) ){

                content = s.build.pluginify.getFunction(steal.text, 0)
                content = '(' + content +')(jQuery)'

            }else if (/steal[.\(]/.test(content)) {

                content = s.build.pluginify.getFunction(content, 0)

                if(content){
                    content =  "(" + content + ")(" + param + ")";
                }
            }

the end result might look something like this.

    //gets content from a steal
    s.build.pluginify.content = function(steal, param, opener){
        if (steal.buildType == 'fn') {
            // if it's a function, go to the file it's in ... pull out the content
            var index = funcCount[steal.rootSrc] || 0, contents = readFile(steal.rootSrc);
            funcCount[steal.rootSrc]++;
            return "(" + s.build.pluginify.getFunction(contents, index) + ")(" + param + ")";
        }
        else {
            //s.print('rooSrc ' + steal.rootSrc)
            var content = readFile(steal.rootSrc);
            //########## added by Jesse Baird 1/15/2013
            //test for view
            //##########
            if( /\.ejs/.test(steal.rootSrc ) ){

                content = s.build.pluginify.getFunction(steal.text, 0)
                content = '(' + content +')(jQuery)'

            }else if (/steal[.\(]/.test(content)) {

                content = s.build.pluginify.getFunction(content, 0)

                if(content){
                    content =  "(" + content + ")(" + param + ")";
                }
            }

            //s.print('steal ' + content )
            //make sure steal isn't in here
            return content;
        }
    };

Hopes this helps, sometime I would like to get around to patching the newest version of steal.

@justinbmeyer
Copy link
Contributor

I'm going to work on fixing this now. Thanks!

@justinbmeyer
Copy link
Contributor

Fixed here with the latest steal: f1b7e74

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

7 participants