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

how to use EJS #11

Open
GoogleCodeExporter opened this issue Mar 14, 2015 · 1 comment
Open

how to use EJS #11

GoogleCodeExporter opened this issue Mar 14, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

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
Copy link
Author

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

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