Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

Any intention to add an 'include' tag to enable nested templates? #42

Open
stringfellow opened this issue Mar 9, 2012 · 6 comments
Open

Comments

@stringfellow
Copy link

I've got a couple of cases where I have a template that I reuse within other templates and at the moment its a copy-paste job. Am I missing something?
Is this a reasonable feature request?

@sircambridge
Copy link

will this work for you ?

<%- eco.render(fs.readFileSync('someTemplate.eco'), @ ) %>

@stringfellow
Copy link
Author

Hmm, possibly. I'm using eco in spinejs and I don't think I have implicit access to the eco module within the template... But am probably missing something.

@sircambridge
Copy link

You might be able to global.eco = require('eco') ?

Or pass the Eco reference into the context object, @eco = require('eco')

Gene Tsai
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Monday, March 19, 2012 at 3:33 AM, Steve Pike wrote:

Hmm, possibly. I'm using eco in spinejs and I don't think I have implicit access to the eco module within the template... But am probably missing something.


Reply to this email directly or view it on GitHub:
#42 (comment)

@trans
Copy link

trans commented Apr 13, 2012

I am compiling eco template using eco command-line and wondering the same thing -- how to nest templates?

@lagartoflojo
Copy link

In my case, I'm sending the templates directly to the clients, and they all get stored in the "JST" variable (this is done automatically by Rails).

To nest a template then, I use:

<%- JST['template_name'](myVar: 1) %>

@timaschew
Copy link

@sircambridge I try this: pass to the outer template the eco, fs, and templateDir object, in the template I do this:

<%- @eco.render( @fs.readFileSync(@templateDir + '/Makefile_partial.eco'), @) %>

But I get an error, whatever the partial contains some string, nochting (empty) or a variable print:

Users/timaschew/project/node_modules/eco/lib/scanner.js:31
      this.source = source.replace(/\r\n?/g, "\n");
               ^
TypeError: Object  has no method 'replace'
  at new Scanner (/Users/timaschew/project/node_modules/eco/lib/scanner.js:31:28)
  at new Preprocessor (/Users/timaschew/project/node_modules/eco/lib/preprocessor.js:17:22)
  at module.exports.Preprocessor.preprocess (/Users/timaschew/project/node_modules/eco/lib/preprocessor.js:12:22)
  at exports.precompile.precompile (/Users/timaschew/project/node_modules/eco/lib/compiler.js:12:35)
  at exports.compile (/Users/timaschew/project/node_modules/eco/lib/compiler.js:19:38)
  at module.exports.eco (/Users/timaschew/project/node_modules/eco/lib/index.js:11:86)
  at Function.eco.render (/Users/timaschew/project/node_modules/eco/lib/index.js:26:13)
  at Object.eval (<anonymous>:74:27)
  at Object.eval (<anonymous>:106:8)
  at eval (<anonymous>:108:6)
  at Function.eco.render (/Users/timaschew/project/node_modules/eco/lib/index.js:26:25)
  at /Users/timaschew/project/tools/create_makefile.coffee:90:17, <js>:107:43
  at fs.js:266:14
  at Object.oncomplete (fs.js:107:15)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants