MithrilJS / mithril.js

A JavaScript Framework for Building Brilliant Applications
https://mithril.js.org
MIT License
14.02k stars 925 forks source link

template-compiler.sjs doesn't work if the code is using Browserify #612

Closed shibukawa closed 8 years ago

shibukawa commented 9 years ago

When I compile template the code that uses Browserify to combine source files, it doesn't convert correctly. The following output file was generated from almost same source code of #611. The source has extra line "var m = require('mithril');".

var m$750 = require('mithril');

:

function view$754() {
    return m$750('div', [
        m$750('input', {
            onchange: m$750.withAttr('value', vm$752.description),
            value: vm$752.description()
        }),
        m$750('button', { onclick: vm$752.add }, 'Add'),
        m$750('table', vm$752.list().map(function (task$756) {
            return m$750('tr', [
                m$750('td', [m$750('input[type=checkbox]', {
                        onclick: m$750.withAttr('checked', task$756.done),
                        value: task$756.done()
                    })]),
                m$750('td', { style: { textDecoration: task$756.done() ? 'line-through' : 'none' } }, task$756.description())
            ]);
        }))
    ]);
}
lhorie commented 8 years ago

I'm now recommending people to use mithril-objectify instead of the sweet.js macros