Open SourceCombine JavaScript and a Template Engine for Flexible Web Apps

Combine JavaScript and a Template Engine for Flexible Web Apps

Developer.com content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

Template engines (TEs) can be very useful in web development scenarios where you need to generate and format text automatically according to specific processing rules. Basically, a TE takes a data model, applies a given template, and produces the result document. These engines can also help you build your applications based on the Model-View-Controller (MVC) pattern, making them more robust and maintainable than applications based on spaghetti code. Most programming languages provide built-in or third-party TEs.

Merging a TE and JavaScript will enable you to build very flexible web applications. Using them together also helps keep the presentation logic separated from the model. So, for example, you could use several templates—which you might load using Ajax—to present the same data through different layouts.

In his Web Developer’s Virtual Library (WDVL) article, Alessandro Lacava shows you how to combine the power of a TE called TrimPath with one of the most used client-side programming languages, JavaScript. In the past, JavaScript was used just for form validation and other “trivial” tasks. However, since the emergence of Ajax, JavaScript has gained more and more popularity among web developers. The capability to make asynchronous calls to the server and update a web page without reloading it made JavaScript a language that no web developer could do without.


Read the full story at Web Developer’s Virtual Library:
Combine JavaScript and a Template Engine for Flexible Web Apps

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Latest Posts

Related Stories