Code Monkey home page Code Monkey logo

embeddedjavascript's People

embeddedjavascript's Issues

how to use EJS

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 [email protected] on 3 Dec 2010 at 10:34

EJS transforms primitive values into objects

render : function(object, extra_helpers){
        object = object || {}
        this._extra_helpers = extra_helpers;
        var v = new EJS.Helpers(object, extra_helpers || {});
        return this.template.process.call(object, object,v);
    },

this should be:
render : function(object, extra_helpers){
        object = typeof object == "undefined" ? {} : object;
        this._extra_helpers = extra_helpers;
        var v = new EJS.Helpers(object, extra_helpers || {});
        return this.template.process.call(object, object,v);
    },

otherwise if object is 0 it will make a {} out of it

Original issue reported on code.google.com by [email protected] on 23 May 2013 at 12:32

Link is removed from inside to outside of the span when template renders

To reproduce the problem use the code above:
            <a href="javascript:;" class="full">

                <span class="lead"></span>
                <span class="pin">

                    <span class="item_name">title</span>

                    <span class="item_sup_info">  0 miles away<br />Call: <a href="tel:323213313">323213313</a></span>

                </span>
                        </a>

When the template renders i get the following:
                        <a href="javascript:;" class="full">
                <span class="lead"></span>
                <span class="pin">
                    <span class="item_name">La Belle Auberge</span>
                    <span class="item_address">54 r Cambronne 75015 Paris</span>
                    <span class="item_sup_info">  0 miles away<br>Call: </span></span></a>
                        <a href="tel:323213313">323213313</a>

Original issue reported on code.google.com by [email protected] on 11 Nov 2011 at 1:22

There is no template at Error in Internet Explorer 11

What steps will reproduce the problem?
1. loading template from given url (e.g. http://abc.com/resources/templ/my.ejs)

What is the expected output? What do you see instead?
calling new EJS({url:"http://abc.com/resources/templ/my.ejs"}) should return 
template from server but inside IE its throwing error that There is no template 
at above given url.

What version of the product are you using? On what operating system?
Windows 7, IE 11

Please provide any additional information below.
loading template work on other browser like firefox and chrome but not in IE


Original issue reported on code.google.com by [email protected] on 3 Jan 2014 at 4:42

EJSView.prototype.partial

Hi, 

Do you have an idea why the partial method was removed in the last version of 
ejs.

Thanks in advance.

Benjamin

Original issue reported on code.google.com by [email protected] on 22 Apr 2010 at 1:32

EJS.update from json url

EJS.update throws javascript error: 'expected ;' in case you pass json url as 
second parameter to update function. It should enclose json string into 
parentheses to work properly(at least in IE9). The fix is to replace line 112 
with var object = eval( '('+request.responseText+')' );

Original issue reported on code.google.com by [email protected] on 11 Jul 2012 at 12:25

String.prototype monkeypatching

rsplit and chop are unnecessary additions to String.prototype, considering
they are only used a combined 3 times, and only within the library. Locally
scoped functions would suffice and would avoid modifications to the global
namespace (important when writing library code.) It seems these additions
are an artifact of the Ruby port, but are unnecessary and potentially
harmful here.

Patch is attached.

Original issue reported on code.google.com by [email protected] on 9 May 2009 at 11:23

Attachments:

Uncaught TypeError: Cannot read property '0' of undefined

In the template I use external variables. For this particular error, I use 
"swk_menu":

var swk_menu = [{"section_link":["Support 
Technique","module","function"],"links":[["name","module","function"],["name","m
odule","function"]]},{"logo_url":"img\/error_FileNotFound.png","logo_name":"test
","logo_module":"","links":[["name","module","function"],["name","module","funct
ion"]]}];

template:
<!-- Build menus -->
<% 
for(m in swk_menu) { 
    var menu = swk_menu[m];
    %>
    <div class="swk_menu">
        <div class="swk_menu_logo">
            <span class="swk_menu_link" onclick="swk.openTab();"><%= menu.section_link[0] %></span><br />
        </div>
        <%
        for(sm in menu.links) {
            var submenu = menu.links[sm];
            %>
            <span class="swk_menu_link" onclick="swk.openTab('<%= submenu[1] %>', '<%= submenu[2] %>');"><%= submenu[0] %></span><br />
            <%      
        }
        %>
    </div>
<% } %>

********************
"menu.section_link[0]" trigger the error. but in the same template I can alert 
it just fine. The same kind of code works well in the "submenu" area.

I don't get it...

Original issue reported on code.google.com by [email protected] on 24 Sep 2011 at 3:55

Render pre-compiled ejs

Hi,

Grunt.js has a plugin that pre-compiles EJS, but I can't figure out how to 
render it. Any ideas?


Original issue reported on code.google.com by [email protected] on 22 Feb 2013 at 9:41

How do you include a static html page in an ejs template?

What steps will reproduce the problem?
1. I have got an ejs template that is displayed via an express powered app.
2. There is an angular template that is duplicated across several ejs templates
3. How can I include this static template in ejs templates so I avoid 
duplication?




Original issue reported on code.google.com by [email protected] on 9 Jan 2014 at 12:16

Can no longer have a helper that begins with "include"

In EJS 0.6.1, I had two view helpers, include_css and include_js. However, upon 
upgrading to 0.8.2, these names caused errors. It seems as if having a view 
helper that begins with the string "include" immediately triggers partial logic?

Original issue reported on code.google.com by [email protected] on 21 Aug 2012 at 5:24

Is it possible to use "if" condition?

What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?


Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 19 Sep 2010 at 7:41

Ternary operator with undefined variables

<%= message ? message : 'No message' %>

When the variable message === undefined, the compiler throws an exception, even 
though a regular IF statement should just evaluate the expression to FALSE.

By the way, this executes correctly:

<%= typeof message != 'undefined' ? message : 'No message' %>


I am using the ejs_1.0_developer release (downloaded two days ago) as a Node.js 
module. [Cygwin environment running on Windows 7]

Original issue reported on code.google.com by [email protected] on 20 Dec 2010 at 7:03

EJS introduces global variables

What steps will reproduce the problem?
1) Use EJS.render inside of a QUnit unit test.
2) Load up the unit tests in a browser.
3) Select "noglobals"
4) Rerun unit tests - watch the test turn red because of "scanline, regex, line"

What is the expected output? What do you see instead?
Expected output - no failing tests with "noglobals" checked
Seeing - failing tests due to introduced global variables with "noglobals" 
checked

What version of the product are you using? On what operating system?
EJS 1.0 on OSX.


See attached unit test.  A fix is contained in file under 
qunit_errors/ejs_fixed.js

Original issue reported on code.google.com by [email protected] on 20 Feb 2012 at 1:24

Attachments:

<h1>,<h2>,<h3> in templates cause "unspecified" error in i.e. 7.

What steps will reproduce the problem?
1. Create an ejs template that uses the [%%] style tags
2. add an <h3> (or any heading tag 1-5) to the template
3. render template

What is the expected output? What do you see instead?
internet explorer gives "unspecified error".  FF/chrome/safari all fine.

What version of the product are you using? On what operating system?
1.0 on PC/internet explorer, and Mac safari/ff/chrome

I have verified, definitively that explorer can't render ejs templates that
include heading tags with numbers in them (i.e. h1, h2, etc.)  working
around by using custom p tags.

Original issue reported on code.google.com by [email protected] on 8 Mar 2010 at 8:05

Escaping HTML

Is it possible to escape/sanitize code, similar to Rails? Example:

<%=h(data) %>,
or
<%=sanitize(data) %>
or probably just a double percentage?
<%%= data %>

I feel this is pretty important feature to have.

Original issue reported on code.google.com by [email protected] on 7 Nov 2010 at 3:36

Ternary operator with undefined variables

<%= message ? message : 'No message' %>

When the variable message === undefined, the compiler throws an exception, even 
though a regular IF statement should just evaluate the expression to FALSE.

By the way, this executes correctly:

<%= typeof message != 'undefined' ? message : 'No message' %>


I am using the ejs_1.0_developer release (downloaded two days ago) as a Node.js 
module. [Cygwin environment running on Windows 7]

Original issue reported on code.google.com by [email protected] on 20 Dec 2010 at 7:11

Error compiling with Closure Compiler

When compiling ejs.js with Closure Compiler 
(https://code.google.com/p/closure-compiler/), I get the following error:

ERROR - The use of scope variable e is not allowed within a catch block with a 
catch exception of the same name.
                    var e = new Error();

This is triggered by ejs.js:365, near the end of the EJS.Compiler.prototype 
definition. The fix is pretty easy: just name the inner declaration of 'e' 
something else.

We're using EJS as part of much larger JS app, and would rather compile it 
together with our other files, rather than use the pre-compiled version. In 
addition, we don't use the view helpers, so this helps cuts down on file size.

Original issue reported on code.google.com by [email protected] on 2 Apr 2013 at 10:24

.update function with only element as function parameter fails

What steps will reproduce the problem?
1. Use .update function with only one parameter (the element where the template 
is shown). If you add a second parameter Hello World appears although the 
second parameter is useless.


What is the expected output? What do you see instead?
Hello World is the expected output. Instead i see nothing.


What version of the product are you using? On what operating system?
CentOs 9.0, Firefox 18.0, Apache/2.2.3


Please provide any additional information below.
Please see the attached example.



Original issue reported on code.google.com by [email protected] on 15 Jan 2013 at 3:16

Attachments:

'type' option hard-coded for 'element' type

What steps will reproduce the problem?
1. var tmpl = new EJS({element:document.getElementById('identification'), 
type:'<'})
2. tmpl.update('something', obj);
3. the un-parsed source of #identification is inserted into #something

What is the expected output? What do you see instead?
the actual parsed template

What version of the product are you using? On what operating system?
latest svn trunk

Please provide any additional information below.
change line 57 of ejs.js on trunk to this:

        this.type = options.type || '['


from this:

        this.type = '['

I use this so i can do 

<script type="template/ejs">
</script>

so i don't have to escape anything in my templates.  better than a pre or area 
tag

:-)

thanks

Original issue reported on code.google.com by [email protected] on 25 Jun 2010 at 4:35

Error using img_tag in IE

My code looks like this

    <% if(action_type == "registration") { %>
        <%= img_tag("/images/actions/news_feed/welcome.png", "welcome", {class : "icon"} %>
    <% } %>

This is giving me an unexpected identifier error in IE 7 and 8. If I remove the 
img_tag and replace it 
with a html include it works correctly.

    <% if(action_type == "registration") { %>
        <img src="/images/actions/news_feed/welcome.png" alt="welcome" class="icon"/>
    <% } %>

Original issue reported on code.google.com by [email protected] on 10 May 2010 at 5:38

JSONP support

Is there any way/are you planning to add JSONP support?

Original issue reported on code.google.com by decurnex.roberto on 30 Dec 2010 at 12:44

Please make the EJS construtor accept element's of type "script"

It would be really nice if the constructor could not only check for "value" or 
"innerHTML" but also "text" to get the value form <script>-elements.
Then it would be possible to embed ejs script on a page without "abusing" the 
usage of textarea just to be able to type '< characters. I.e. it would be 
possible to do:
<script type="text/ejs">
<li>
    <a href='supplies/<%= supplies[i] %>'>
        <%= supplies[i] %>
    </a>
</li>
</script>

I have tested this approach on pretty much all browsers and it works like a 
charm, other libraries use it as well, such as dojo for their templating.

Original issue reported on code.google.com by [email protected] on 21 Jan 2011 at 1:47

Comments

Would it be possible to add the <%-- --%> comment "escape"? 

Thanks 

Original issue reported on code.google.com by [email protected] on 13 Oct 2009 at 8:00

Push html content into template

What steps will reproduce the problem?
1. adding html elements in render call.
2.
3.

What is the expected output? What do you see instead?
I wanted to see html content to be pushed inside my template

What version of the product are you using? On what operating system?


Please provide any additional information below.
I am calling  new 
EJS({url:(server+"resources/templates/parent.ejs")}).render({loading:loadIcon.ad
dLoader("sdf")[0]}); 

where loadIcon.addLoader("sdf")[0] return one html body, how can I push this 
html to my template file ?

I tried to use tag() view but no help.. any idea ?

Original issue reported on code.google.com by [email protected] on 30 Nov 2013 at 8:14

Will EJS work alongside ASP.NET?

What steps will reproduce the problem?
1. Load Visual Studio 2010
2. Create new website solution
3. Try using EJS

What is the expected output? What do you see instead?

Expect to see page validated correctly and ready to build. Instead we would 
supposedly see many errors saying the back-end code is not valid or recognised.

What version of the product are you using? On what operating system?

Any version of EJS that uses <% %> as it's tag markers. Any operating system.

Please provide any additional information below.

Was this discussed before using an already atandard tag marker? Are there any 
plans to make this framework work alongside ASP.NET? What were the developers 
thinking when they came up withtheir <% %> tag markers?

Original issue reported on code.google.com by [email protected] on 23 May 2012 at 3:36

invalid label for ejs.update(element, url)

What steps will reproduce the problem?

on firefox 3.5.9, open untar invalid_label_bug.tgz and open test.html,
firebug will report "invalid label"

What is the expected output? What do you see instead?

There should be no error.

What version of the product are you using? On what operating system?

ejs 1.0 developer on firefox 3.5.9+firebug 1.5.4 on ubuntu

Please provide any additional information below.

see 
- http://willcode4beer.com/tips.jsp?set=jsonInvalidLabel
-
http://www.bennadel.com/blog/99-JSON-Minor-But-VERY-Important-Detail-Creating-Sy
ntax-Error-Invalid-Label.htm


Original issue reported on code.google.com by boris.w.lau on 9 May 2010 at 6:03

Attachments:

Javascript error in IE8

I try to display a list of elements (users in this case). Il works perfectly in 
Firefox and Chrome, but I have an error in IE (the list doesn't appears).

Error given by IE : 
----------------------------------
Message : '(' expected
Line : 357
Character : 3
Code : 0
URI : http://localhost/.../ejs.js
----------------------------------

Here is my code... in the js file :

render("list.html", {users: users});

And then, in HTML page :

<% for each(user in users) { %>
    <tr id="user-<%= user.id %>">
        <td><%= user.name %></td>
        <td><%= user.login %></td>
        <td><%= user.password %></td>
        <td><a href="#/user/<%= user.id %>">View details</a></td>
    </tr>
<% } %>


Line 357 in EJS 1.0 corresponds to :
try{
    eval(to_be_evaled);
}catch(e){

Do you have any idea of what could cause this? Does it result from my code or 
from EJS ?

Thank you in advance for your reply (and sorry for my broken English !).

Original issue reported on code.google.com by [email protected] on 3 Aug 2010 at 9:31

"EJS is not defined" in Internet Explorer 9

What steps will reproduce the problem?
1. include "ejs.js"
2. var something = new EJS([..]);
3. error

What version of the product are you using? On what operating system?

Using latest Internet Explorer 9 (rc) and latest EJS

Original issue reported on code.google.com by [email protected] on 3 Mar 2011 at 8:05

Update function with differend templates

What steps will reproduce the problem?
1. Call (new EJS(options)).update(element) twice with differend templates and 
elements

What is the expected output? What do you see instead?
Expected different functions that updates only template which has been called 
by. Instead of this all functions try to update last template which has call 
update function.

What version of the product are you using? On what operating system?
1.0 Window 7 x86 Chrome  20

Please provide any additional information below.
I think problem with closure. Variable _template replaced by 'this' value of 
last object that call function update;
Fix (lines 102-105):

return (function(_template){
    return function(object){
        EJS.prototype.update.call(_template, element, object);
    };
}(this));

Original issue reported on code.google.com by [email protected] on 17 Apr 2012 at 12:26

htmlentities

What steps will reproduce the problem?
1. encode value with htmlentities (from phpjs)
2. add it in a input text value=""
3. input displays "&quot;"

What is the expected output? What do you see instead?

Using latest google chrome.

expected: "
instead: &quot;

I have to fix them after pageload:

$("input[type=text]").each(function() {
  $(this).val(html_entity_decode($(this).val()));
});

if I reinput the original value via google chrome debug console, it's decoded 
proprely
12:13 <~Sirber> niaiserie de


Original issue reported on code.google.com by [email protected] on 11 Nov 2011 at 5:43

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.