Closed Bug 741582 Opened 12 years ago Closed 12 years ago

kuma/script: include a template that includes a library

Categories

(developer.mozilla.org Graveyard :: Wiki pages, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: groovecoder, Unassigned)

References

Details

(Whiteboard: u=contributor c=wiki s=2012-04-10 t=2012-04-17 p=1)

e.g.,

Template:test_lib:
{%
exports.add = function(a, b) {
  return a+b;
};
%}

Template:include_lib:
{% var test_lib = require('test_lib'); %}
{%= test_lib.add(1,2) %}

Template:test_include:
This template should be able to include a library template like:
 
{% var test_lib = require('test_lib'); %}
{%= test_lib.add(5,6) %}
 
And should output into any template itself.

test-template:
1+2: {{ include_lib }} //works

Including test_include:

{{ test_include }}


The last line causes:
    TemplateExecutionError — Problem executing template for template : TypeError: ejs:3 1| This template should be able to include a library template like: 2| >> 3| {% var test_lib = require('test_lib'); %} 4| {%= test_lib.add(5,6) %} 5| 6| And should output into any template itself. Cannot read property 'exports' of undefined
I think the error is actually that `require()` doesn't work twice in a row, and it's probably due to something going wrong with my attempts at internal caching.

I changed test_include to this and got an error on both the test_include and include_lib macros at the end:

1+2: {{ include_lib(1) }} //works

Including test_include: {{ test_include }}

1+2: {{ include_lib(2) }} //works
Next step is to wrap this up in a nodeunit test & fixtures, and see if that will reproduce it before a fix
If I understand this bug right, this PR fixes it:

https://github.com/mozilla/kumascript/pull/6
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Whiteboard: u=contributor c=wiki s=2012-04-24 t=2012-04-17 p= → u=contributor c=wiki s=2012-04-10 t=2012-04-17 p=1
Version: Kuma → unspecified
Component: Website → Landing pages
Product: developer.mozilla.org → developer.mozilla.org Graveyard
You need to log in before you can comment on or make changes to this bug.