Skip to end of metadata
Go to start of metadata

CSS, HTML, Smarty & Twig Coding Standards

Regarding the CSS and HTML codebase, because we have integrated Bootstrap 4 both in the back office and front office of PrestaShop 1.7, we have decided to follow their coding standards, maintained by @mdo.

When you are writing HTML code, if your line is longer than 120 characters, we have chosen to do a line break after each attributes with an indentation. For example, it will look like this:

Some noteworthy rules:

  • HTML
    • Use soft tabulations with two spaces to indent.
    • Avoid superfluous HTML markup.
    • No more self-closing tag.
  • CSS
    • Use soft tabulations with two spaces to indent.
    • When grouping selectors, keep individual selectors to a single line.
    • End all declarations with a semicolon, even the last one.

 

PrestaShop 1.7 uses both the Smarty and Twig template engine. Since those are mostly used to generate HTML, we expect the Smarty/Twig code to comply with the HTML standards above – as well as the one used by SensioLabs for Twig.

Some noteworthy rules:

  • Use soft tabulations with two spaces to indent.
  • Use single quotes to surround strings.
  • Use snake case (underscores) to name your blocks.

 


  • No labels