btwael / mammouth

Unfancy PHP
http://mammouth.boutglay.com
MIT License
214 stars 22 forks source link

mammouth.compile not working with Jade filters via Grunt #36

Closed Grawl closed 8 years ago

Grawl commented 10 years ago

I don't know where I can get help with this so I will write this issue into all related repositories: this, gruntjs/grunt-contrib-jade#103 and visionmedia/jade#1503.

I am trying to add Mammouth filter to grunt-contrib-jade.

filters.js

var jadefilters=module.exports={};
jadefilters.mammouth=function(str){
    return require('mammouth').compile(str);
};

gruntfile.coffee

        jade:
            compile:
                options:
                    data:(dest,src) ->
                        return require('./locals.json')
                    filters: require('./filters.js')
                files:[
                    expand:true
                    cwd:'<%=locals.path.src%>/templates/'
                    src:'*.jade'
                    dest:'<%=locals.path.dev%>'
                    ext:'.php'
                ]

index.jade

doctype html
html
    body
        :mammouth
            list = [1, 2, 3, 4, 5]

And I get this:

Running "jade:compile" (jade) task
[ { type: 'embed', content: 'list = [1, 2, 3, 4, 5]' } ]
File test/index.php created.

So I have Mammouth code instead of compiled PHP.

index.php

<!DOCTYPE html><html><body>list = [1, 2, 3, 4, 5]</body></html>

But I want to get this:

index.php

<!DOCTYPE html><html><body><?$list = array(1, 2, 3, 4, 5);?></body></html>

mammouth is installed globally and in a project with sudo npm install --save.

btwael commented 8 years ago

@Grawl l just rewrite mammouth from zero with large changes, check it you're problem is solved http://mammouth.wamalaka.com/

Grawl commented 8 years ago

@btwael oh cool will try it on weekend!