templates - Alternative to Dynamic Includes In Jade -


what alternative solution trying use dynamic includes using express + jade? here i'm trying following setup:

  • routes
    • index.js
    • widgets.js
  • views
    • widgets
      • widget1.jade
    • index.jade
    • widget.jade
  • app.js

in app.js, specify following route:

app.get('/widgets/:widget', widgets.widgets);

in widgets route, widgets.js have:

exports.widgets = function(req, res){res.render('widgets/' + req.params.widget);};

this gives me ability view widget on own browsing /widgets/widget1. works great. can include widget in view this

include widgets/widget1 

this works great too. however, want add widget2 , want show widget1 , show widget2 within page. had hoped pass variablewidgetname view , reference this:

include widgets/#{variablewidgetname} 

this fails. when try access page, 500 error stating no such file or directory views\widgets#{variablewidgetname}.jade exists. cannot reference variables includes.

what other options have. if limitation in jade, there different approach should using? i've thought of loading widget via ajax hoped better solution using jade or express.

does know of better way this?

try using partial instead of include.

here works me (i use harpjs.com jade, uses "jade": "0.35.0"):

- var name = "something" != partial('./'+name+'/hello.md')`


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -