machty / emblem.js

Emblem.js - Ember-friendly, indented syntax alternative for Handlebars.js
http://emblemjs.com
MIT License
1.04k stars 81 forks source link

Mustache nested in text does not work with pipe #222

Open ryanlntn opened 9 years ago

ryanlntn commented 9 years ago

I'm getting the following errors after trying to upgrade to 0.5.0:

Parse error on line 1:
...{{link-to 'contact' | Contact}} support.
-----------------------^
Expecting 'CLOSE', 'CLOSE_UNESCAPED', 'STRING', 'INTEGER', 'BOOLEAN', 'OPEN_SEXPR', 'CLOSE_SEXPR', 'ID', 'DATA', got 'INVALID'
Error: Parse error on line 1:
...{{link-to 'contact' | Contact}} support.
-----------------------^
Expecting 'CLOSE', 'CLOSE_UNESCAPED', 'STRING', 'INTEGER', 'BOOLEAN', 'OPEN_SEXPR', 'CLOSE_SEXPR', 'ID', 'DATA', got 'INVALID'

The emblem template code in question:

#{link-to 'contact' | Contact} support.

I tried removing all the pipes and now I'm seeing:

Error while processing route: index 
Unknown template object: function Error
  at http://localhost:3000/assets/frontend/vendor-b7a9ee40048d47a4bc4e9411d7a7dd9a.js?body=1:10644:25
  at http://localhost:3000/assets/frontend/vendor-b7a9ee40048d47a4bc4e9411d7a7dd9a.js?body=1:10648:3
  at __module4__.string (http://localhost:3000/assets/frontend/vendor-b7a9ee40048d47a4bc4e9411d7a7dd9a.js?body=1:10502:42)
  at http://localhost:3000/assets/frontend/vendor-b7a9ee40048d47a4bc4e9411d7a7dd9a.js?body=1:10504:2

  logError                    @ ember.js:26275
  defaultActionHandlers.error @ ember.js:26232 
  triggerEvent                @ ember.js:26323
  trigger                     @ ember.js:47549
  Transition.trigger          @ ember.js:47394
  finalizeTransition          @ ember.js:46582
  (anonymous function)        @ ember.js:45984
  tryCatch                    @ ember.js:47983
  invokeCallback              @ ember.js:47995
  publish                     @ ember.js:47966
  (anonymous function)        @ ember.js:29463
  Queue.invoke                @ ember.js:849
  Queue.flush                 @ ember.js:914
  DeferredActionQueues.flush  @ ember.js:719
  Backburner.end              @ ember.js:144
  Backburner.run              @ ember.js:199
  run                         @ ember.js:17906
  ember$data$lib$system$adapter$$Adapter.extend.ajax.Ember.RSVP.Promise.hash.success @ rest_adapter.js:892
  jQuery.Callbacks.fire                  @ jquery.js:3144
  jQuery.Callbacks.self.fireWith         @ jquery.js:3256
  done                                   @ jquery.js:9310
  jQuery.ajaxTransport.send.callback     @ jquery.js:9714

I'm not sure what I'm doing wrong here. The plaintext example on http://emblemjs.com/syntax/ seems to indicate my template is correct and it was working before I switched over.

ryanlntn commented 9 years ago

I just tried adding the following test:

test('link-to test', function(){
  compilesTo("| #{link-to 'aroute' | Some Text}", "{{link-to 'aroute'}}Some Text{{/link-to}}");
});

and got:

229) text: pipe character: link-to test

     compilesTo assertion failed:
    Emblem:   "| #{link-to 'aroute' | Some Text}"
    Expected: "{{link-to 'aroute'}}Some Text{{/link-to}}"
    Actual:   "{{link-to 'aroute' | Some Text}}"

Is this expected behavior? How are people handling inline links?

mixonic commented 9 years ago

@ryanlntn this looks like a regression, there was no test for this syntax :-(

bantic commented 9 years ago

@ryanlntn If you run into other problems you can live-preview emblem compilation here: http://bantic.github.io/try-emblem/. And yes, this does look like a regression. Thanks for reporting it.