im trying to use templates for my basic views. I tried this with underscore.template to run it. The problem is that there are some security restrictions with the manifest_version 2 chrome extension. I think the reason is that inline blocks are no longer allowed. In this small example, I download a template and try to display it. Then I get the error message:
Fault Error: code generation from lines forbidden for this context.
I tried this also with Handlebars.js and the template directly in my html file. It works in a normal browser window. But this is not like an extension of chrome.
So how can I use templates with backbone.js in the chrome extension with manifest_version 2?
Underlined (not working):
define [
'jquery'
'backbone'
'lib/facade'
'text!templates/loginTemplate.js'
],
($, Backbone, facade, LoginTemplate) ->
'use strict'
class LoginView extends Backbone.View
tagName: 'div'
events: {
}
initialize: (options) ->
@el = options.el
render: ->
console.log 'LoginView: render()'
$(@el).html(_.template(LoginTemplate, {}))
with handles (does not work):
in index.html:
<script id="loginTemplate" type="text/x-handlebars-template">
<form class="form-horizontal">
<fieldset>
<legend>Login</legend>
<div class="control-group">
<label class="control-label" for="email">Email:</label>
<div class="controls">
<input type="text" class="input-xlarge" id="email" name="email">
</div>
</div>
<div class="control-group">
<label class="control-label" for="password">Passwort:</label>
<div class="controls">
<input type="password" class="input-xlarge" id="password" name="password">
</div>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-primary">Login</button>
</div>
</fieldset>
</form>
</script>
and, in my opinion:
define [
'jquery'
'backbone'
'lib/facade'
],
($, Backbone, facade) ->
'use strict'
class LoginView extends Backbone.View
tagName: 'div'
events: {
}
initialize: (options) ->
@el = options.el
render: ->
console.log 'LoginView: render()', $("#loginTemplate")
$(@el).html(Handlebars.compile($("#loginTemplate").html()))
source
share