beimingrj / embeddedjavascript

Automatically exported from code.google.com/p/embeddedjavascript
Other
0 stars 0 forks source link

how to use EJS #11

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hello,
I am new, I do not understand why this code does not work.

My html :
<html>
 <head>
  <script type="text/javascript" src="ejs_production.js"></script>
 </head>
 <body>  
  <script type="text/javascript">
   var data =  {supplies : ['mop', 'broom', 'duster']};
   var result = new EJS({url: 'templates/cleaning.ejs'}).render(data);
   document.getElementById('supply_list').innerHTML = result
  </script>
 </body>
</html>

My template :
<!--template/cleaning.ejs-->
<h1>Supplies</h1>
<ul>
<% for(var i = 0; i<supplies.length; i++) {%>
   <li><%= supplies[i] %></li>
<% } %>
</ul>

Help me, thank you

Original issue reported on code.google.com by christia...@ac-rennes.fr on 3 Dec 2010 at 10:34

GoogleCodeExporter commented 9 years ago
it work for me , just create a function & action into id(element)

<html>
 <head>
  <script type="text/javascript" src="ejs_production.js"></script>

  <script type="text/javascript">
   var data =  {supplies : ['mop', 'broom', 'duster']};
   var result = new EJS({url: 'cleaning.ejs'}).render(data);

   function show(){
        document.getElementById('supply_list').innerHTML = result       
   }   
  </script>
 </head>

 <body id="supply_list">  
  <p onclick="show()">Click Here</p>
 </body>
</html>

Original comment by hendar.o...@gmail.com on 25 May 2012 at 9:05