question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to deal with JsRender error exceptions during server-side compiling or rendering?

See original GitHub issue

Hi, I have the following structure (forget the twig extension, its left from my nunjucks tests):

            var appData ={};
            res.render('layout', appData, function(err, html) {
               res.send(html);
            });
test

{{include tmpl='./_includes/footer.html'}} 
//if i remove the import, the template get rendered and shows 'test'

I get no errors , just a white page.

How to apply this on the server :

        $.views.settings.debugMode(true);

Is this correct :

jsrender.views.settings.debugMode(true)

Whats missing please?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
BorisMoorecommented, Mar 24, 2016

“./…” paths are relative paths - they are relative to the calling script - in your case app.js. They are nothing to do with Express.

You need to write {{include tmpl='./templates/test.html' /}}

OTOH if you use Hapi or Express, you can define the templates directory location, and then write res.render('_includes/footer', ... where you are using an Express API - hence the path is relative to the templates folder you set up for Express, and you are omitting the .html extension, since you set that up too for express.

JsRender ‘./…’ paths work equally well whether you use Express, Hapi, or neither.

All that is shown in the samples here https://github.com/BorisMoore/jsrender-node-starter, and the docs here http://www.jsviews.com/#node/filetmpls.

Did you start from those samples? If so you should have been starting from the correct ./... relative paths…

1reaction
BorisMoorecommented, Mar 24, 2016

Sure!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Specifying onError fallback behavior on a tag - JsRender
The onError fallback string will be rendered whenever there an error (or exception) is encountered during the tag rendering. Setting to the empty...
Read more >
Is there a way to fix this Server Side Rendering Error
I just want to use Server Side Rendering to Render a Component In my project. *ERROR in ./server.js Module build failed (from ....
Read more >
Server side rendering JavaScript from PHP \ Seb De Deyne
Let's review some server side rendering concepts, benefits and tradeoffs, and build a server renderer in PHP from first principles.
Read more >
Handling runtime errors when server side rendering with Next.js
Let's take a look of ways how can we avoid a webpage from crashing in production?
Read more >
Client Side Templating with JsRender - DotNetCurry.com
Developers familiar with server side technologies like WebForms on ASP ... In the next section, we see how to render the above with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found