Ask HN: Server-side HTML Templates based on DOM?
3 by PaulHoule | 1 comments on Hacker News.
For side projects I've used BeautifulSoup in Python to break down HTML documents into the DOM, manipulate them at the DOM level, then serve them to a browser. For instance the "main template" for a site could be an HTML page that has ainside it which is a placeholder for the content. The content is itself an HTML page, and the of the content is inserted into the
, also the metadata gets merged so the
For side projects I've used BeautifulSoup in Python to break down HTML documents into the DOM, manipulate them at the DOM level, then serve them to a browser. For instance the "main template" for a site could be an HTML page that has ainside it which is a placeholder for the content. The content is itself an HTML page, and the of the content is inserted into the
, also the metadata gets merged so the
3 by PaulHoule | 1 comments on Hacker News.
For side projects I've used BeautifulSoup in Python to break down HTML documents into the DOM, manipulate them at the DOM level, then serve them to a browser. For instance the "main template" for a site could be an HTML page that has a
First Name:
and the system would insert the firstName into that span, for instance. I've done the same thing in Java with tools like jsoup and HTMLUnit. This system can rewrite links and do other interesting transformations on the guest HTML. One thing I'll concede is that this is slow compared to the alternatives. In a crude test a system like this and not optimized might be able to transform 10-50 pages per second on a core whereas it is easy to get 3000+ with string based templates. I haven't seen other people do this, are there any examples you of know of DOM-based templating? Any thoughts?For side projects I've used BeautifulSoup in Python to break down HTML documents into the DOM, manipulate them at the DOM level, then serve them to a browser. For instance the "main template" for a site could be an HTML page that has a
First Name:
and the system would insert the firstName into that span, for instance. I've done the same thing in Java with tools like jsoup and HTMLUnit. This system can rewrite links and do other interesting transformations on the guest HTML. One thing I'll concede is that this is slow compared to the alternatives. In a crude test a system like this and not optimized might be able to transform 10-50 pages per second on a core whereas it is easy to get 3000+ with string based templates. I haven't seen other people do this, are there any examples you of know of DOM-based templating? Any thoughts? 1 https://ift.tt/6L2MtWv 3 Ask HN: Server-side HTML Templates based on DOM?
Comments
Post a Comment