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

Allow double quotes in template strings #2121

Merged
merged 2 commits into from
Oct 30, 2013
Merged

Conversation

jieter
Copy link
Contributor

@jieter jieter commented Oct 23, 2013

Fixes #2120.

And:

  • some space -> tab replacements
  • make Mocha ignore leaks.

@@ -107,6 +107,7 @@ L.Util = {

compileTemplate: function (str, data) {
// based on https://gist.github.com/padolsey/6008842
str = str.replace(/"/g, '\\\"');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be chained with the next line, right? And if this is going to be a continuing oddness I really wonder if fancy template compilation is worth it.

@mourner
Copy link
Member

mourner commented Oct 25, 2013

Not sure we want to make this a general-purpose templating utility... I made it lightweight specifically for templating URLs, and it's unlikely to see doubles quotes in URLs...

@tmcw
Copy link
Contributor

tmcw commented Oct 25, 2013

Even though, it seems like if the thesis is "interpolate variables in a string" then the behavior shouldn't have an unpredictable implementation-specific quirk like this.

@mourner
Copy link
Member

mourner commented Oct 25, 2013

Then we should probably also fix line breaks, all kinds of weird symbols, etc. Or we could just updated the docs to state that it's specifically used to interpolate URLs.

@tmcw
Copy link
Contributor

tmcw commented Oct 25, 2013

Yeah... part of my unease here is because the old-fashioned non-compiled version was less quirky and the change didn't seem justified by perf in #1968

@mourner
Copy link
Member

mourner commented Oct 25, 2013

After some clean up, it turned out to be quite short so I think it was justified :)

@tmcw
Copy link
Contributor

tmcw commented Oct 25, 2013

I think this is a case in which short != simple, especially in terms of behavior.

@mourner
Copy link
Member

mourner commented Oct 25, 2013

Maybe, but I like it. Leaflet was never meant to have powerful general-purpose framework facilities after all, and it works great for Leaflet needs.

@jieter
Copy link
Contributor Author

jieter commented Oct 26, 2013

'Simble templating facilty' doesn't sound to me like something that does not support something common like double quotes. You might consider the ease of writing and reading the docs for it as well.

<script>
mocha.setup({
ui: 'bdd',
ignoreLeaks: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also comment on why this is needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mocha.ignoreLeaks() did not make mocha ignore leaks at my setup, resulting in lots of tests failing, while this syntax fixes that.

mocha.ignoreLeaks(true) also does the job. This method was changed in Mocha (mochajs/mocha@d6330cb)

I should have done it in a separate pull though, shall I make a new PR for the (non-template) spec related stuff and remove it from this one?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, I wonder what's different in your setup if Travis builds current Leaflet just fine...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was asking myself that question too...

If I put back the original

mocha.setup('bdd');
mocha.ignoreLeaks();

it fails again, if I add true, the leaks are properly ignored...

$ npm list | grep mocha
├── karma-mocha@0.1.0
├─┬ mocha@1.13.0

mourner added a commit that referenced this pull request Oct 30, 2013
Allow double quotes in template strings
@mourner mourner merged commit cc2b03f into Leaflet:master Oct 30, 2013
@mourner
Copy link
Member

mourner commented Oct 30, 2013

Decided to merge. Thanks @jieter!

@jieter jieter deleted the util-template branch October 30, 2013 14:55
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

Successfully merging this pull request may close these issues.

L.Util.template fails for templates with double quotes.
3 participants