Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

Template.dynamic appears to be broken #75

Closed
dweldon opened this issue Oct 19, 2014 · 9 comments
Closed

Template.dynamic appears to be broken #75

dweldon opened this issue Oct 19, 2014 · 9 comments
Labels

Comments

@dweldon
Copy link

dweldon commented Oct 19, 2014

Ui.dynamic has been replaced with Template.dynamic. However, this:

+Template.dynamic(template=template)

Gives me this error: Expected template or null, found: undefined

{{> Template.dynamic template=template}}

Works correctly if it's in an .html file, but not when it's in a .jade file.

@mquandalle mquandalle added the bug label Oct 19, 2014
@erasmus
Copy link

erasmus commented Oct 23, 2014

can you give a hint where this can be fixed?

@erasmus
Copy link

erasmus commented Oct 24, 2014

I can't get it to work here. Do you have a working example where you put a real template for "template"? Thanks.

@mquandalle
Copy link
Owner

Since meteor-jade is just an other syntax than spacebars, I test this package by writting two templates one using spacebars and the other using jade, and by checking that both template compile to the exact same JavaScript code, which is the case here. Do you have an example of template inclusion not working with jade but working with spacebars? (Otherwise it's probably a bug somewhere else).

@mquandalle mquandalle added question and removed bug labels Oct 25, 2014
@applecat
Copy link

Here is an example, that works well with spacebars, but does not work in jade.

Works well in HTML:
cover.coffee

templateName = 'passwordForm'
Blaze.renderWithData Template.cover, {templateName: templateName}, $('body')[0]

cover.html

<template name="cover">
  {{> Template.dynamic template=templateName}}
</template>

login.jade

template(name="passwordForm")
  p Some form definition here

When I change cover.html to cover.jade:

template(name="cover")
  +Template.dynamic(template=templateName)

I have this in console:
Uncaught Error: Expected template or null, found: undefined

Error thrown here (spacebars-runtime.js:23):

  var view = Blaze.View('Spacebars.include', function () {
    var template = templateVar.get();
    if (template === null)
      return null;

    if (! Blaze.isTemplate(template))
      throw new Error("Expected template or null, found: " + template);

    return template.constructView(contentFunc, elseFunc);
  });

templateVar.get() function returns undefined. But I do not understand why.

@mquandalle mquandalle added bug and removed question labels Nov 14, 2014
@mquandalle mquandalle reopened this Nov 14, 2014
@mquandalle
Copy link
Owner

It seems that there is a problem that @dweldon, @rashagen, @applecat, and @acemtp encounter, but unfortunately I cannot reproduce it. Clonable repository anyone?

@dweldon
Copy link
Author

dweldon commented Nov 14, 2014

Upgrading to 0.2.9 fixed it for me.

@mquandalle
Copy link
Owner

Hum, maybe that's why I cannot reproduce it, and why the test pass :)

@applecat
Copy link

Thanx, upgrading to 0.2.9 really fix this issue.

@Sivli-Embir
Copy link

Sorry sorry never mind, I am a dork. Case issue: Template not template.

DISREGARD

Sorry to bump a closed issue but I am having this problem (0.4.1).

+template.dynamic(template='hello')

I tested it in a fresh meteor app with the initial html file converted to jade:

Uncaught Error: Expected template or null, found: undefined

The crazy thing is this works:

+UI.dynamic(template='hello')

I am on METEOR@1.1.0.2

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

No branches or pull requests

5 participants