baryshev / ect

Fastest JavaScript template engine with embedded CoffeeScript syntax
http://ectjs.com
MIT License
626 stars 70 forks source link

Не работает с requirejs #25

Closed khomyakov42 closed 11 years ago

khomyakov42 commented 11 years ago

'libs/coffee-script': { exports: 'CoffeeScript', init: ()-> return window.CoffeeScript = this }, 'libs/ect': { deps: ['libs/coffee-script'], init: () -> return ECT(root: '/assets/templates', ext: '.ect') },

Ошибка Uncaught TypeError: Cannot call method 'compile' of undefined in /assets/templates/index.ect

darky commented 11 years ago

You can resolve this issue, modify end of file extra/coffee-script.js:

// "function" == typeof define && define.amd ? define(function() {
//     return CoffeeScript
// }) : root.CoffeeScript = CoffeeScript
root.CoffeeScript = CoffeeScript

This modification force assign to window object - CoffeeScript, that necessary for ECT


Ты можешь пофиксить это, изменив конец файла extra/coffee-script.js следующим образом:

// "function" == typeof define && define.amd ? define(function() {
//     return CoffeeScript
// }) : root.CoffeeScript = CoffeeScript
root.CoffeeScript = CoffeeScript

Данное изменение в любом случае даст присвоить объекту window - CoffeeScript, что нужно для нормальной работы ECT

darky commented 11 years ago

Hey, it's issue not resolved. And trick with coffee not right. Ect should natively support this situation.


Рано закрывать эту проблему. Трюк с coffee - временное решение. Ect должен сам разруливать эту ситуацию с requirejs и coffee.

darky commented 11 years ago

Add pull request #37 But this potentially can raise error, if *.ect template will start load before coffee-script loaded. So you can tune your require.config for avoid this situation:

This guarantees, that coffee-script will load before ect


Добавил pull request #37 Но теоритечески может возникнуть ошибка, если *.ect шаблоны начнут грузиться до того, как coffee-script был загружен. Но вы можете поправить ваш require.config для избежания этой ситуации.

Это гарантирует, что coffee-script будет загружен до ect

baryshev commented 11 years ago

Now ECT defined lowercase ect RequireJS module that depends on lowercase coffee-script module.