assemble / assemble-swig

Assemble engine plugin for swig templates.
MIT License
10 stars 2 forks source link

Relative include/extends are broken with expand=true #7

Open noirbizarre opened 10 years ago

noirbizarre commented 10 years ago

When using expand=true in the assemble task, all includes and import are broken.

Ex:

If you have the following layout:

├ data/
├ templates/
│ ├ base.swig
│ ├ index.swig
│ └ other.swig
├ out/
└ Gruntfile.js

and the following assemble task definition:

assemble: {
    options: {
        engine: 'swig',
        data: 'data/*.{json|yaml}'
    },
    site: {
       expand: true,
       cwd: 'templates',
       src: [
            'index.swig',
            'other.swig',
        ],
        dest: 'out'
    }
}

None of these syntaxes is working in index.swig (same for {% include %}:

{% extends "base.html" %}
{% extends "./base.html" %}

I have to write:

{% extends "templates/base.html" %}

Next, if i want to extends this template into other.swig, I can't because none of this is working:

{% extends "index.swig" %}
{% extends "./index.swig" %}
{% extends "templates/index.swig" %}

It can't resolve base.swig and produce the following error:

Assembling out/index.html OK
Assembling out/other.html ERROR
Warning: ENOENT, no such file or directory 'ROOT/templates/templates/base.swig' Use --force to continue.

or

Assembling out/index.html OK
Assembling out/other.html ERROR
Warning: ENOENT, no such file or directory 'ROOT/base.swig' Use --force to continue.

The same error happens with this task definition:

assemble: {
    options: {
        engine: 'swig',
        data: 'data/*.{json|yaml}'
    },
    site: {
       expand: true,
       src: [
            'templates/index.swig',
            'templates/other.swig',
            'templates/about.swig',
        ],
        dest: 'out',
        flatten: true
    }
}
jonschlinkert commented 10 years ago

thanks for the heads up. we'll look into this

noirbizarre commented 10 years ago

Thanks, by advance! This issue makes it unusable right now !

noirbizarre commented 10 years ago

Any news ?