Why node js is not recognizing ending brackets for ejs












-2















i am creating an image gallery in node js using express and ejs
The following is the code for my app.js



var express = require('express');
var app = express();
app.set("view engine", "ejs");
app.get("/", function(req, res){
res.render("welcome");
});

app.get("/campground", function(req, res){

var campground = [
{name : "Salmon Creek", image :
"http://www.onguma.com/uploads/1/1/7/5/117537555/201604-aoba-
935_2_orig.jpg"},

{name : "Granite Hill", image : "https://d2y0su6ixv655t.cloudfront.net/wp-
content/uploads/2014/07/16115316/BR15102803V_069.jpg"},

{name : "Mountain Goat's Rest", image :


"https://www.colorado.com/sites/default/files/styles/1000x685/public/TroutLakeCamping_DC2.jpg?itok=2UO32aZ_"}
];



res.render("campground", {campground:campground});
});

app.listen(5000, function(){
console.log("Server has been started");
})


Now for campground the following is the ejs file


This is the campground page



  <% campground.forEach(function(camp){ %>
<div>
<h4><%= camp.name %></h4>
<img src="<%= camp.image %>">
</div>
<% >})%>
<a href="/">Home Page</a>


Node is confusing %> for img tag brackets in image tag in above line



and following error is generated



  SyntaxError: Unexpected token > in 
/projects/Backendt/YelpCamp/views/campground.ejs while compiling ejs

If the above error is not helpful, you may want to try EJS-Lint:
https://github.com/RyanZim/EJS-Lint
Or, if you meant to create an async function, pass async: true as an
option.
at new Function (<anonymous>)
at Template.compile
(/projects/Backendt/YelpCamp/node_modules/ejs/lib/ejs.js:618:12)
at Object.compile
(/projects/Backendt/YelpCamp/node_modules/ejs/lib/ejs.js:389:16)
at handleCache
(/projects/Backendt/YelpCamp/node_modules/ejs/lib/ejs.js:212:18)
at tryHandleCache
(/projects/Backendt/YelpCamp/node_modules/ejs/lib/ejs.js:251:16)
at View.exports.renderFile [as engine]
(/projects/Backendt/YelpCamp/node_modules/ejs/lib/ejs.js:482:10)
at View.render
(/projects/Backendt/YelpCamp/node_modules/express/lib/view.js:135:8)
at tryRender
(/projects/Backendt/YelpCamp/node_modules/express/lib/application.js:640:10)
at Function.render
(/projects/Backendt/YelpCamp/node_modules/express/lib/application.js:592:3)
at ServerResponse.render
(/projects/Backendt/YelpCamp/node_modules/express/lib/response.js:1008:7)


**Plz tell me how to insert image using ejs code for above case










share|improve this question



























    -2















    i am creating an image gallery in node js using express and ejs
    The following is the code for my app.js



    var express = require('express');
    var app = express();
    app.set("view engine", "ejs");
    app.get("/", function(req, res){
    res.render("welcome");
    });

    app.get("/campground", function(req, res){

    var campground = [
    {name : "Salmon Creek", image :
    "http://www.onguma.com/uploads/1/1/7/5/117537555/201604-aoba-
    935_2_orig.jpg"},

    {name : "Granite Hill", image : "https://d2y0su6ixv655t.cloudfront.net/wp-
    content/uploads/2014/07/16115316/BR15102803V_069.jpg"},

    {name : "Mountain Goat's Rest", image :


    "https://www.colorado.com/sites/default/files/styles/1000x685/public/TroutLakeCamping_DC2.jpg?itok=2UO32aZ_"}
    ];



    res.render("campground", {campground:campground});
    });

    app.listen(5000, function(){
    console.log("Server has been started");
    })


    Now for campground the following is the ejs file


    This is the campground page



      <% campground.forEach(function(camp){ %>
    <div>
    <h4><%= camp.name %></h4>
    <img src="<%= camp.image %>">
    </div>
    <% >})%>
    <a href="/">Home Page</a>


    Node is confusing %> for img tag brackets in image tag in above line



    and following error is generated



      SyntaxError: Unexpected token > in 
    /projects/Backendt/YelpCamp/views/campground.ejs while compiling ejs

    If the above error is not helpful, you may want to try EJS-Lint:
    https://github.com/RyanZim/EJS-Lint
    Or, if you meant to create an async function, pass async: true as an
    option.
    at new Function (<anonymous>)
    at Template.compile
    (/projects/Backendt/YelpCamp/node_modules/ejs/lib/ejs.js:618:12)
    at Object.compile
    (/projects/Backendt/YelpCamp/node_modules/ejs/lib/ejs.js:389:16)
    at handleCache
    (/projects/Backendt/YelpCamp/node_modules/ejs/lib/ejs.js:212:18)
    at tryHandleCache
    (/projects/Backendt/YelpCamp/node_modules/ejs/lib/ejs.js:251:16)
    at View.exports.renderFile [as engine]
    (/projects/Backendt/YelpCamp/node_modules/ejs/lib/ejs.js:482:10)
    at View.render
    (/projects/Backendt/YelpCamp/node_modules/express/lib/view.js:135:8)
    at tryRender
    (/projects/Backendt/YelpCamp/node_modules/express/lib/application.js:640:10)
    at Function.render
    (/projects/Backendt/YelpCamp/node_modules/express/lib/application.js:592:3)
    at ServerResponse.render
    (/projects/Backendt/YelpCamp/node_modules/express/lib/response.js:1008:7)


    **Plz tell me how to insert image using ejs code for above case










    share|improve this question

























      -2












      -2








      -2








      i am creating an image gallery in node js using express and ejs
      The following is the code for my app.js



      var express = require('express');
      var app = express();
      app.set("view engine", "ejs");
      app.get("/", function(req, res){
      res.render("welcome");
      });

      app.get("/campground", function(req, res){

      var campground = [
      {name : "Salmon Creek", image :
      "http://www.onguma.com/uploads/1/1/7/5/117537555/201604-aoba-
      935_2_orig.jpg"},

      {name : "Granite Hill", image : "https://d2y0su6ixv655t.cloudfront.net/wp-
      content/uploads/2014/07/16115316/BR15102803V_069.jpg"},

      {name : "Mountain Goat's Rest", image :


      "https://www.colorado.com/sites/default/files/styles/1000x685/public/TroutLakeCamping_DC2.jpg?itok=2UO32aZ_"}
      ];



      res.render("campground", {campground:campground});
      });

      app.listen(5000, function(){
      console.log("Server has been started");
      })


      Now for campground the following is the ejs file


      This is the campground page



        <% campground.forEach(function(camp){ %>
      <div>
      <h4><%= camp.name %></h4>
      <img src="<%= camp.image %>">
      </div>
      <% >})%>
      <a href="/">Home Page</a>


      Node is confusing %> for img tag brackets in image tag in above line



      and following error is generated



        SyntaxError: Unexpected token > in 
      /projects/Backendt/YelpCamp/views/campground.ejs while compiling ejs

      If the above error is not helpful, you may want to try EJS-Lint:
      https://github.com/RyanZim/EJS-Lint
      Or, if you meant to create an async function, pass async: true as an
      option.
      at new Function (<anonymous>)
      at Template.compile
      (/projects/Backendt/YelpCamp/node_modules/ejs/lib/ejs.js:618:12)
      at Object.compile
      (/projects/Backendt/YelpCamp/node_modules/ejs/lib/ejs.js:389:16)
      at handleCache
      (/projects/Backendt/YelpCamp/node_modules/ejs/lib/ejs.js:212:18)
      at tryHandleCache
      (/projects/Backendt/YelpCamp/node_modules/ejs/lib/ejs.js:251:16)
      at View.exports.renderFile [as engine]
      (/projects/Backendt/YelpCamp/node_modules/ejs/lib/ejs.js:482:10)
      at View.render
      (/projects/Backendt/YelpCamp/node_modules/express/lib/view.js:135:8)
      at tryRender
      (/projects/Backendt/YelpCamp/node_modules/express/lib/application.js:640:10)
      at Function.render
      (/projects/Backendt/YelpCamp/node_modules/express/lib/application.js:592:3)
      at ServerResponse.render
      (/projects/Backendt/YelpCamp/node_modules/express/lib/response.js:1008:7)


      **Plz tell me how to insert image using ejs code for above case










      share|improve this question














      i am creating an image gallery in node js using express and ejs
      The following is the code for my app.js



      var express = require('express');
      var app = express();
      app.set("view engine", "ejs");
      app.get("/", function(req, res){
      res.render("welcome");
      });

      app.get("/campground", function(req, res){

      var campground = [
      {name : "Salmon Creek", image :
      "http://www.onguma.com/uploads/1/1/7/5/117537555/201604-aoba-
      935_2_orig.jpg"},

      {name : "Granite Hill", image : "https://d2y0su6ixv655t.cloudfront.net/wp-
      content/uploads/2014/07/16115316/BR15102803V_069.jpg"},

      {name : "Mountain Goat's Rest", image :


      "https://www.colorado.com/sites/default/files/styles/1000x685/public/TroutLakeCamping_DC2.jpg?itok=2UO32aZ_"}
      ];



      res.render("campground", {campground:campground});
      });

      app.listen(5000, function(){
      console.log("Server has been started");
      })


      Now for campground the following is the ejs file


      This is the campground page



        <% campground.forEach(function(camp){ %>
      <div>
      <h4><%= camp.name %></h4>
      <img src="<%= camp.image %>">
      </div>
      <% >})%>
      <a href="/">Home Page</a>


      Node is confusing %> for img tag brackets in image tag in above line



      and following error is generated



        SyntaxError: Unexpected token > in 
      /projects/Backendt/YelpCamp/views/campground.ejs while compiling ejs

      If the above error is not helpful, you may want to try EJS-Lint:
      https://github.com/RyanZim/EJS-Lint
      Or, if you meant to create an async function, pass async: true as an
      option.
      at new Function (<anonymous>)
      at Template.compile
      (/projects/Backendt/YelpCamp/node_modules/ejs/lib/ejs.js:618:12)
      at Object.compile
      (/projects/Backendt/YelpCamp/node_modules/ejs/lib/ejs.js:389:16)
      at handleCache
      (/projects/Backendt/YelpCamp/node_modules/ejs/lib/ejs.js:212:18)
      at tryHandleCache
      (/projects/Backendt/YelpCamp/node_modules/ejs/lib/ejs.js:251:16)
      at View.exports.renderFile [as engine]
      (/projects/Backendt/YelpCamp/node_modules/ejs/lib/ejs.js:482:10)
      at View.render
      (/projects/Backendt/YelpCamp/node_modules/express/lib/view.js:135:8)
      at tryRender
      (/projects/Backendt/YelpCamp/node_modules/express/lib/application.js:640:10)
      at Function.render
      (/projects/Backendt/YelpCamp/node_modules/express/lib/application.js:592:3)
      at ServerResponse.render
      (/projects/Backendt/YelpCamp/node_modules/express/lib/response.js:1008:7)


      **Plz tell me how to insert image using ejs code for above case







      node.js backend






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 3 at 16:01









      Soham NathaniSoham Nathani

      1




      1
























          1 Answer
          1






          active

          oldest

          votes


















          1














          This:



          <% >})%>


          Should be this:



          <% })%>





          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54025818%2fwhy-node-js-is-not-recognizing-ending-brackets-for-ejs%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            This:



            <% >})%>


            Should be this:



            <% })%>





            share|improve this answer




























              1














              This:



              <% >})%>


              Should be this:



              <% })%>





              share|improve this answer


























                1












                1








                1







                This:



                <% >})%>


                Should be this:



                <% })%>





                share|improve this answer













                This:



                <% >})%>


                Should be this:



                <% })%>






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 3 at 16:17









                robertkleprobertklep

                140k19237251




                140k19237251
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54025818%2fwhy-node-js-is-not-recognizing-ending-brackets-for-ejs%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Monofisismo

                    Angular Downloading a file using contenturl with Basic Authentication

                    Olmecas