Pergunta

I typically set up jquery templates in my html files like this:

<script id="some-template" type="text/x-jquery-tmpl">
  my template contents go here... with some data: {data}
</script>

then my javascript that needs to use this template would look for it by the id and pass in the needed data:

var template = $("#some-template");
var html = template.tmpl({data: "data goes here..."});
// do something with the 'html' var, like attach it to the DOM

now i'm trying to write jasmine-bdd specs for my javascript. i don't see anything particularly wrong with the way i set up my templates and have my javascript find / expand the template... but i'm not sure how to get jasmine to play nice with this... so...

how can i use jasmine to test my javascript, when my javascript relies on a jquery-template, and the template is defined in my html page directly?

do i have to duplicate my template in a jasmine-jquery fixture? or is there a way to make a jasmine-jquery fixture use my existing html / template definition?

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top