Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

twig.Template is undefined #16

Open
minixxie opened this issue Aug 8, 2012 · 0 comments
Open

twig.Template is undefined #16

minixxie opened this issue Aug 8, 2012 · 0 comments

Comments

@minixxie
Copy link

minixxie commented Aug 8, 2012

Hi,

I'm using symfony 2.0.1 with vendors, and installed JMSTwigJsBundle:

deps file:

[symfony]
    git=http://github.com/symfony/symfony.git
    version=v2.0.1

[twig]
    git=http://github.com/fabpot/Twig.git
    version=v1.1.2

...etc...

[JMSTwigJsBundle]
    git=https://github.com/schmittjoh/JMSTwigJsBundle.git
    target=/bundles/JMS/TwigJsBundle

[twig.js]
    git=https://github.com/schmittjoh/twig.js.git

on my javascript part, I've added:

<script src="http://closure-library.googlecode.com/svn/trunk/closure/goog/base.js"></script>

{% javascripts
        "../vendor/twig.js/twig.js"
%}
    <script language="javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}

{% javascripts "@ABCBundle/Resources/views/User/userDiv.html.twig"
       filter="twig_js" %}
    <script language="javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}

userDiv.html.twig is something like:

{% twig_js name="userDiv" %}
<div...
...
</div>

Then I render it in my JS:

... Twig.render(userDiv, {name: "Johannes"}) ...

Sorry for passing Johannes' name but I think that should not matter.

Then the Javascript console of firefox shows me "twig.Template is undefined". It is saying this line in bold text:

/**
 * @fileoverview Compiled template for file
 *
 * 
 */

goog.provide('userDiv');

/**
 * @constructor
 * @param {twig.Environment} env
 * @extends {twig.Template}
 */
userDiv = function(env) {
    twig.Template.call(this, env);
};
twig.inherits(userDiv, twig.Template);

/**
 * @inheritDoc
 */
userDiv.prototype.getParent_ = function(context) {
    return false;
};

Do you have any idea?
I'm not familiar with the google closure things, nor the mechanism of this bundle... but I just followed the doc provided in JMSTwigJsBundle and twig.js. (except that the doc doesn't state that google closure's JS should be included, otherwise it says "goog is undefined", so I included the http://closure-library.googlecode.com/svn/trunk/closure/goog/base.js as you can see above)

Many Thanks.
Simon

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

No branches or pull requests

1 participant