Skip to content

Latest commit

 

History

History
122 lines (92 loc) · 2.12 KB

EXAMPLES.md

File metadata and controls

122 lines (92 loc) · 2.12 KB

Usage with Assemble

Use this helper in a "parent" layout:

{{#prettify}}
  {{> body }}
{{/prettify}}

See nested layouts.

Indent Example

Before

Using the indent hash option:

Template: index.hbs

{{#prettify indent="2"}}
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <h1>My Blog</h1> <h2>Post of the day</h2> <p> Vestibulum posuere, quam sed bibendum posuere Pellentesque habitant morbi tristique senectus Pellentesque nulla augue, volutpat vitae </p> <a href="#">Read more...</a> </body> </html>
{{/prettify}}

After

Renders to:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Document</title>
  </head>
  <body>
    <h1>My Blog</h1>
    <h2>Post of the day</h2>
    <p>
      Vestibulum posuere, quam sed bibendum posuere
      Pellentesque habitant morbi tristique senectus
      Pellentesque nulla augue, volutpat vitae
    </p>
    <a href="#">Read more...</a>
  </body>
</html>

Condense Example

Before

<!DOCTYPE html>
<html lang="en">
  <head>

    <!-- code comment -->
    <meta charset="UTF-8">
    <title>Document</title>


  </head>


  <body>
    <h1>My Blog</h1>
    <h2>Post of the day</h2>


    <!-- scripts -->
    <a href="#">Read more...</a>


  </body>
</html>

Example output with condensed: true:

After

<!DOCTYPE html>
<html lang="en">
  <head>
    <!-- code comment -->
    <meta charset="UTF-8">
    <title>Document</title>
  </head>
  <body>
    <h1>My Blog</h1>
    <h2>Post of the day</h2>
    <!-- scripts -->
    <a href="#">Read more...</a>
  </body>
</html>

Newlines

When used with condense, defining padcomments: true will result in something like this:

<!DOCTYPE html>
<html lang="en">
  <head>

    <!-- code comment -->
    <meta charset="UTF-8">
    <title>Document</title>
  </head>
  <body>
    <h1>My Blog</h1>
    <h2>Post of the day</h2>

    <!-- scripts -->
    <a href="#">Read more...</a>
  </body>
</html>