node.js - With an express app, how to use my schema data in css/stylus? -
i'm trying create themes express app , i'm trying i'm not sure possible. need expert advice on ways or methods this.
this schema...
var colorschema = new schema({ primarycolor: { type: string }, secondarycolor: { type: string } }); module.exports = mongoose.model('color', colorschema); let's i've entered hex colors primarycolor , secondarycolor when create new schema. how can parse color.primarycolor value in css or stylus in jade?
be sure first pass data jade through render in express:
// default both white res.render('template_name', { primarycolor: color.primarycolor || '#fff', secondarycolor: color.secondarycolor || '#fff', someothervar: 'foo' }); then, in jade template:
style(type='text/css') | .primary-color-bg { background-color: #{primarycolor}; } | .secondary-color-bg { background-color: #{secondarycolor}; } you can apply primary-color-bg , secondary-color-bg classes dom elements want set background of. can replicate color, border, etc. attributes.
Comments
Post a Comment