Minimalizing HTML content

Is there a way to minimalize HTML content?

For example, let's say I have a regular HTML document such as:

<html>


<title>A title or something</title>  

  <h2>Blah blah blah times 5 </h2>
  <p>
  Blah blah blah times 5Blah blah blah times 5Blah blah blah times 5Blah blah blah times 5Blah blah blah times 5Blah blah blah times 5Blah blah blah times 5Blah blah blah times 5Blah blah blah times 5Blah blah blah times 5Blah blah blah times 5Blah blah blah times 5Blah blah blah times 5Blah blah blah times 5
  </p>


</html>

I would rather if possible do something like this:

<html>


<title>{title of page}</title>  

  <h2>{header information}</h2>
  <p>
{Paragraph information}
  </p>


</html>

I'm not sure how the html page would know it's getting that information but I'm looking just to see if this is possible or not.

Answers 1

  • You probably want to use a library like Handlebars. There are other similar libraries out there as well so take care to research which is best for you.

    Handlebars will allow you to use the {{something}} format to minimise the information you code into your html. Others will use a similar, if not the same, format.

    Building on that, you could also switch to using an MVC framework (such as Angular or Ember) which include similar "mustache" style templating and other helpful features in order to make your dynamic content easier to code. Ember actually uses Handlebars, Angular uses it's own "directives" which are very similar. Other MVC frameworks with included templating are available as well.


Related Articles