tj / consolidate.js

Template engine consolidation library for node.js
3.48k stars 353 forks source link

How to use partials DustJS in ExpressJS 4.x? #245

Open extensionsapp opened 8 years ago

extensionsapp commented 8 years ago

Hello.

I use ExpressJS 4.

var config = {};

config.theme = 'MyTheme';

var express    = require('express');
var path         = require('path');
var app          = express();

var cons = require('consolidate');
app.engine('tl', cons.dust);

app.set('views', [
    path.join(__dirname, 'themes', 'skeleton', 'views'),
    path.join(__dirname, 'themes', config.theme, 'views')
]);

app.set('view engine', 'tl');

...

themes/skeleton/views/index.tl

Hello 
{>"navigation"/}

themes/skeleton/views/navigation.tl

World

UPD:

Empty page, but if I change {>"/home/test.com/themes/skeleton/views/navigation.tl"/} normal echo Hello World.

How to /home/test.com/themes/skeleton/views/navigation.tl change -> navigation.tl?

It looks like a bug in the processing array views.

chebum commented 8 years ago

Add parameter { views: 'themes/skeleton/views/' } to consolidate options. This will fix the problem with dustjs.