loading...

node pug compilefile

twitter logo github logo ・1 min read

loving node pug more and more everyday you can even turn a PUG template into a JS function and call it to generate more HTML

https://pugjs.org/api/reference.html

NODE.JS

  var fn = pug.compileFile('./templates/table.pug', {})

  var html = fn({tablerows: [[4,5], [6,7]]});
  console.log(html)
  var html = fn({tablerows: [[8,9], [1,2]]});
  console.log(html)

TABLE.PUG

as before
OUT.HTML
<table><tr><td>4</td><td>5</td></tr><tr><td>6</td><td>7</td></tr></table>
<table><tr><td>8</td><td>9</td></tr><tr><td>1</td><td>2</td></tr></table>

twitter logo DISCUSS
Classic DEV Post from Sep 30 '19

Hacktoberfest for beginners - Low hanging contribution opportunities

Clive Da profile image
open source webdev & open source devops