Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Having trouble converting this Jade to EJS

Having trouble converting this Jade to EJS

Problem

I am attempting to utilize the Jshare module for Node/Express.

The example given on Github says:

Next, you need to make a call out to the JShare helper method in your layout file:

!!!
html
  head
    title= title
    link(rel='stylesheet', href='/stylesheets/style.css')
    !{includeJShare()}
  body!= body

So, this example is in Jade. I am using EJS, and for the life of me, I can't figure out how to implement the helper method... This seems so simple, but I'm not sure what !{} does in Jade, or how to replicate it in EJS.

Problem courtesy of: minttoothpick

Solution

!{var} is unescaped interpolation in jade. You should be able to get the same thing in ejs by doing:


This should write in a tag.

Edit

If ejs tries to parse include, submit a patch request to https://github.com/brooklynDev/JShare/issues (or to ejs) and in the meantime go into node_modules/JShare/jshare.js and change res.locals.includeJShare to just res.locals.JShare and then use JShare() in your ejs.

Solution courtesy of: glortho

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Having trouble converting this Jade to EJS

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×