New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

render-async

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

render-async

renders a template, possibly asynchronously with an object

1.0.7
latest
Source
npm
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

render-async

An express template renderer that uses an object to potentially render asynchronously. Supported are layout():

<% locals.title = "Rich's Calendar"; layout('_layout.js.html') %><p>Rich was Here</p>

and in _layout.js.html:

<!Doctype html><html><body><%= body() %></body></html>

include(), which always uses jQuery.ajax to do the including so that we can include dynamic resources too:

<!Doctype html><body>included from http://localhost:8080/test <p><%include('http://localhost:8080/test')%></p></body></html>

Of course relative resources can be included too:

<!Doctype html><body>included from _included.js.html <p><%include('_included.js.html')%></p></body></html>

Finally partials can be included:

<ul><% partial('partialinner.js.html', [{test: 1}, {test: 2}]) %></ul>

Or the collection to be iterated over by the partial can be pulled in with jQuery.ajax like so:

<ul><% partial('partialinner.js.html', '/test2') %></ul>

In both cases the same partialinner.js.html is used:

<li><%= test %></li>

This is intended to be a step on the way to a progressive enhancement type web app that runs on a node server with backbone on the client to give a good experience to both browsers and crawlers or browsers with javascript turned off. To this end there is also a link() method that pulls a resource like a text/template in to a page as it is. The idea being that, in one go a page could be delivered to a browser that would have everything needed to run, with or without javascript.

i18n (gettext(), __()) is also supported through the i18n-abide library.

Keywords

Node.js

FAQs

Package last updated on 30 Apr 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts