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

hyphen in computed property declaration #18

Open
heartsentwined opened this issue Aug 20, 2013 · 1 comment
Open

hyphen in computed property declaration #18

heartsentwined opened this issue Aug 20, 2013 · 1 comment

Comments

@heartsentwined
Copy link

This throws an unexpected token error at the 2nd and 3rd hyphens (-):

class App.FooController extends Em.ObjectController
  needs: ['bar-baz']

  +computed controllers.bar-baz.someOtherAttr # error here
  someAttr: ->
    @controllers.bar-baz.someOtherAttr # and here

even though they are perfectly valid when declared in the full syntax:

class App.FooController extends Em.ObjectController
  needs: ['bar-baz']

  someAttr: (->
    @controllers.get('bar-baz').someOtherAttr
  ).property('controllers.bar-baz.someOtherAttr')
@heartsentwined
Copy link
Author

As for what the heck I'm meddling around with hyphens, it's the confusion from naming conventions.

The issue over at stefanpenner/ember-app-kit#74 seems to suggest that template names are to be named in dasherized style. The official docs also suggest data-template-name="a-template". Going further, I cannot find docs on what a corresponding route should be named, but so far I have only had success with a full set of routes, controllers, views, and templates, all named in dasherized style (I'm on a Rails-Sprockets stack):

App.Router.map ->
  @route 'bar-baz'

# template at templates/bar-baz.emblem (or .hbs - no difference)
# view at views/bar-baz.em
# controller at controllers/bar-baz.em

And that brings us back to the reference in the needs syntax in controllers. Declaring it camel-case style does work:

class App.FooController extends Em.ObjectController
  needs: ['barBaz']

  +computed controllers.barBaz.someOtherAttr
  someAttr: ->
    @controllers.barBaz.someOtherAttr

but as per the issues referenced above, perhaps these should parallel the requirement for view names and/or suggested template names?

P.S. Writing up to here, I have a feeling that this might be an ember-level issue after all; but then, if it a dasherized version is valid, then perhaps ember-script should allow it too?

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

1 participant