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

Dot in Variable Passed With Route Url #287

Closed jclaytonsmith closed 6 years ago

jclaytonsmith commented 7 years ago

Whenever clicking a link that references a variable with a dot as its value the application fails to respond.

I have a link on one of my pages like so:

ul li = link-to 'linkDestination' | LinkName

With the resource defined as follows:

App.Router.map ->
this.resource 'linkDestination', { path: '/foo/:passed_Variable/linkDestination' }, () -> this.route('new') this.route('edit', { path: '/:passed_Variable/edit' }) this.route('erase', { path: '/:passed_Variable/erase' })`

However, the business has decided that the value of this particular passed_Variable (pull from a database) is a period: string passed_Varible = "."

The same link works correctly when variable_Passed is anything but a period. After clicking the link, browser displays the correct URL: http://localhost:port/#/foo/./linkDestination

Some configuration information: Using EmberJS as well as CoffeeScript. Grunt is used for pre-compilation. Database is SQL Server 2012.

Edit: New to github, not sure how to get the indentation formatted correctly. Used four spaces but that didn't work. Know that the indentation in the program is indeed correct.

thec0keman commented 7 years ago

Could you give an example of what the unexpected output is here? Also, I'd suggest testing out your implementation on something like Ember Twiddle with raw handlebars to confirm if the issue is Emblem or Ember related.

jclaytonsmith commented 7 years ago

The site largely allows the displaying and editing of database information. Each page displays the rows in an associated table, with each page on the site being for one table. Now, due to the structure of the database, the ID of a row on the current page often has to be passed through a route.

For example, http://localhost:port/#/regions/1/facilities accesses a page that lists all the facilities in the region that has regionID = '1'

For whatever reason, the ID of one of our regions is a period ('.') and that is not likely to change. When trying to access http://localhost:port/#/regions/./facilities the associated page does not render.

The reason I suspect Ember/Emblem is that the call never reaches my c# code when the passed variable is a period, and instead gets lost somewhere in the emblem and js files. Everything works when it isn't a period.

thec0keman commented 7 years ago

Can you verify that this is Emblem and not Ember related? One way would be either to set up a fiddle, or to use a normal handlebars template with the code that is not working.

Like, if your code looks something like this:

= link-to 'Facilities' facilityId

(where facilityId could be a number or a period) then the issue is Ember and not Emblem. Emblem does not execute code (so it does not ever parse the value of variables), it just converts its syntax to normal handlebars. If you can confirm that a normal handlebars expression works then we can investigate further.

Thanks!

jclaytonsmith commented 7 years ago

Thank you so much for your responses! This has been most insightful. I am going to work on replacing the Emblem with plain Handlebars to test your hypothesis. Though, I am expecting your analysis to be correct.