Import HTML snippets into HAML?

Is there a way to import HTML snippets or HAML snippets into a PHP-like HAML file include

?

There are basically HTML snippets for different modules (navigation, footer, carousel, etc.) in separate files (nav.haml, footer.haml, etc.) that can be imported into haml files, so when the files haml files are translated to HTML, imported HTML files are also imported.

Example:

body  
    import(path/to/nav.haml)  
    .container  
        HAML CODE   
    import(path/to/footer.haml)

      

+3


source to share


1 answer


Yes, sir. It was called partial.

body
  =render 'nav'
  .container
    -# HAML CODE
  =render 'footer'

      



By convention, partials will follow this name with an underscore prefix:

_nav.html.haml
_footer.html.haml
index.html.haml

      

+6


source







All Articles