I have three pug files: a.pug, b.pug and c.pug:
block header
style
.
body {...}
if (option.a == 'yes')
include a.css
if (option.b == 'yes')
include b.css
#main-a
p This is page A ....
block header
style
.
body {...}
if (option.a == 'yes')
include a.css
if (option.b == 'yes')
include b.css
#main-b
p This is page B ....
block header
style
.
body {...}
if (option.a == 'yes')
include a.css
if (option.b == 'yes')
include b.css
#main-c
p This is page C ....
They share the same logic under the style
block:
if (option.a == 'yes')
include a.css
if (option.b == 'yes')
include b.css
Is there any way to make the logic in a specific file so I can include it from my three pug files later? Otherwise, if I need to modify the logic, like adding a new line like:
if (option.c == 'yes')
include c.css
I have to make changes to all three pug files.
Thanks for any tips.
You can put the logic in an external file. The variables can be processed from there as well.
a.pug, b.pug, c.pug, ...
block header
include styles.pug
#main-a
p This is page ....
styles.pug
style.
body {...}
if (option.a == 'yes')
include a.css
if (option.b == 'yes')
include b.css