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

3.2 beta 2: incorrect path generation for this.view in controller #70

Closed
wclr opened this issue Sep 27, 2011 · 13 comments
Closed

3.2 beta 2: incorrect path generation for this.view in controller #70

wclr opened this issue Sep 27, 2011 · 13 comments

Comments

@wclr
Copy link

wclr commented Sep 27, 2011

3.2 beta 2:

in controller with more than one word name (for example my_more_than_one_word_controller)
this.view("view_name", params) tries to get view with path:

my_app/views/mymorethanoneword/view_name

and i suppose it should:

my_app/views/my_more_than_one_word/view_name

so underline character is missed.

@daffl
Copy link
Contributor

daffl commented Sep 27, 2011

Based on the new folder structure ( http://edge.javascriptmvc.com/docs.html#!organizing ) it should get

my_app/more_than_one_word/views/view_name

How are you calling this.view?

@wclr
Copy link
Author

wclr commented Sep 27, 2011

well i just call this.view("view_name")

my controller plugin name is "more_than_one_word"

it tries to get my_app/views/morethanoneword/view_name

so it tries morethanoneword (as a solid word) instead of more_than_one_word

@wclr wclr closed this as completed Sep 27, 2011
@wclr wclr reopened this Sep 28, 2011
@wclr
Copy link
Author

wclr commented Sep 28, 2011

hm.. I did not closed it consciously at least

@moschel
Copy link
Member

moschel commented Sep 30, 2011

can you provide a breaking test case?

@moschel
Copy link
Member

moschel commented Sep 30, 2011

I added this test to jquery/controller/view/test recently:

test("complex paths nested inside a controller directory", function(){
$.Controller.extend("Myproject.Controllers.Foo.Bar");

    var path = jQuery.Controller._calculatePosition(Myproject.Controllers.Foo.Bar, "init.ejs", "init")
    equals(path, "//myproject/views/foo/bar/init.ejs", "view path is correct")

})

Yours is a variation of that it sounds like

@justinbmeyer
Copy link
Member

I'm going to close this. Please provide a breaking case (and test code) and reopen it.

@wclr
Copy link
Author

wclr commented Oct 6, 2011

Well, maybe your concept has changed, but what I mean was:

Myproject.Controllers.FooBar (For and Bar without dot). And in 3.1 i've got "_" (underline symbol between "foo" and "bar" in the generated path to a view ("foo_bar") and now I've got just "foobar"

To be more concrete:
I just compared the code in 3.1 and 3.2 in controoler/view/view.js
function _calculatePosition in 3.2 (and calculatePosition in 3.1)

So lets my controller class full name be: Project.Controllers.FooBar

The point is that in 3.1:
controller_name = Class._shortName
and what we got there was: controller_name = foo_bar
and then the calculated path to view: vews/foo_bar/view_name.ejs

and in 3.2 there is some sophisticated code for controller_name and final view path, and so we've got now:
controller_name = foobar (without underline symbole between Foo and Bar)
and a path to view: vews/foobar/view_name.ejs

@wclr
Copy link
Author

wclr commented Oct 6, 2011

It says I can not reopen this issue

@justinbmeyer justinbmeyer reopened this Oct 6, 2011
@justinbmeyer
Copy link
Member

To be concrete, can't you just say something like:

In 3.1:

A.B.FooBar looks in a/b/foo_bar

but in 3.2

A.B.FooBar looks in a/b/foobar

Is that is what is happening?

@justinbmeyer
Copy link
Member

essentially the _ is getting lost.

@wclr
Copy link
Author

wclr commented Oct 6, 2011

Yes, exaclty.

@daffl
Copy link
Contributor

daffl commented Oct 6, 2011

This would be the breaking test:

$.Controller.extend("Myproject.Controllers.FooBar");
path = jQuery.Controller._calculatePosition(Myproject.Controllers.FooBar, "init.ejs", "init")
equals(path, "//myproject/views/foo_bar/init.ejs", "view path is correct")

daffl pushed a commit that referenced this issue Oct 6, 2011
@daffl
Copy link
Contributor

daffl commented Oct 6, 2011

Ok it should be fixed now. Just needed to run the controller name through jQuery.String.underscore.

@daffl daffl closed this as completed Oct 6, 2011
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

4 participants