Navigation

Home
Search
Submit A Resource
Contact Us
About Functionn

Subscription Options


Subscribe By Email (265+)


Lists


Archives

Apr 26, 2012

Author: Hirvesh Posted At: 4/26/2012 Tags: , , ,

Laconic - Laconic Is A Lightweight Approach To Generating DOM Content In JavaScript

Share:
Laconic is a lightweight approach to generating DOM content in JavaScript. The source code is available on GitHub.  Consider the code necessary to produce a simple table hierarchy with the standard DOM API:


This code is beyond verbose, which makes determining the resulting hierarchy difficult. Let's take a look at the laconic way to generate the same table:


Laconic adds a method to the $.el namespace for all known HTML tags. These methods should be invoked with a variable length list of child elements or strings. An optional attributes object may be passed as the first argument. For example:


will produce the following structure:


You can even register your own custom 'tags' that define a particular hierarchy of known elements. You just need to provide a name for your tag, and a function that appends content to 'this', which is a reference to the root node of the tag. For example:


Once you've registered a tag, you can start inserting it:


This particular invocation will produce the following structure:




Requirements: None
Demohttp://joestelmach.github.com/laconic/
License: MIT License

Daily Posts, Be Updated, Subscribe:

Want Free Web Resources? Enter Your Email And We'll Send It To You - Daily! (265+ Subscribers)

Yup, it's that straight forward! Enter your email address below and we'll send you the latest web resources to your inbox, everyday. We don't do spam. Ever.

Trending Posts On Functionn This Week

Share:

Other Interesting Resources:

0 comments:

Post a Comment

 


Recent Posts

Popular Categories



Popular Components



Popular Licenses