Skip to content

Instantly share code, notes, and snippets.

@StephanHoyer
Last active November 19, 2015 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StephanHoyer/58c92f3835c2b2f4b75d to your computer and use it in GitHub Desktop.
Save StephanHoyer/58c92f3835c2b2f4b75d to your computer and use it in GitHub Desktop.
Basic example of a j2c-mithril integration - http://jsfiddle.net/qe805q4q/1/
var styler = require('./styler');
function mainView() {
return [
styler.view(),
//...
];
}
var styler = require('./styler');
var m = require('mithril');
var cls = styler.attach({
foo: {
background: 'green'
}
});
function someRandomView() {
return m('span.' + cls.foo, 'Some random content');
}
var m = require('mithril');
var j2c = require('j2c');
var styles = '';
module.exports = {
attach: function(style) {
var scopedStyle = j2c.scoped(style);
styles += scopedStyle;
return scopedStyle;
},
view: function() {
return m('style', styles);
}
};
@StephanHoyer
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment