Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
khomyakov42 opened this issue Apr 1, 2013 · 4 comments
Closed

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

khomyakov42 opened this issue Apr 1, 2013 · 4 comments

Comments

@khomyakov42
Copy link

'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
Copy link

darky commented Apr 12, 2013

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
Copy link

darky commented Apr 22, 2013

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


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

@khomyakov42 khomyakov42 reopened this Apr 24, 2013
darky pushed a commit to darky/ect that referenced this issue Sep 29, 2013
@darky
Copy link

darky commented Sep 29, 2013

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:

  • add in require.config.paths - "ect": "<relative path to ect>"
  • add in require.config.paths - "coffee-script": "<relative path to coffee-script>"
  • add in require.config.shim - "ect" : {"deps": ["coffee-script"]}

This guarantees, that coffee-script will load before ect


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

  • Добавьте в require.config.paths - "ect": "<относительный путь до ect>"
  • Добавьте в require.config.paths - "coffee-script": "<относительный путь до coffee-script>"
  • Добавьте в require.config.shim - "ect" : {"deps": ["coffee-script"]}

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

@baryshev
Copy link
Owner

baryshev commented Oct 5, 2013

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

kuba-kubula added a commit to apiaryio/ect that referenced this issue Nov 12, 2014
* commit '0edfa8c4283153128363b53878e1bbdc4e6211c5':
  Fix bower config
  Fix typo
  Fix typo in bower.json
  Add bower integration
  Fix for baryshev#9
  Fix for baryshev#16
  Possible fix for baryshev#16
  update README.md example
  remove .ect suffix when in template include and extend
  remove suffix when res.render
  Clear cache public API
  Fix for unescaped regular expressions baryshev#47
  Remove node_modules
  RequireJS support. Fix baryshev#25.
  Update CoffeeScript version
  Fix compilation error
  Command line compiler

Conflicts:
	lib/ect.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants