markbates / markbates/coffeebeans
Add CDATA section to coffee_script_tag
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 228
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
Is there any reason for `coffee_script_tag` to not render JS inside a CDATA section as `javascript_tag` would do?
``` erb
<%= javascript_tag do%>
<%= coffee_script do %>
if 2 < 0
alert('uh?')
<% end %>
<% end %>
```
the code above would render the following html that is friendly to any xml/html parser:
``` html
//<![CDATA[
(function() {
if (2 < 0) {
alert('uh?');
}
}).call(this);
//]]>
```
instead of doing the same `coffee_script_tag` renders the code without wrapping it in `CDATA` turning html to not be well formed anymore (eg. `2 < 0`):
``` erb
<%= coffee_script_tag do%>
if 2 < 0
alert('uh?')
<% end %>
```
``` html
(function() {
if (2 < 0) {
alert('uh?');
}
}).call(this);
```
Thanks
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the coffee_script_tag helper and compare its output with javascript_tag, as shown in the issue examples. Check how the generated CoffeeScript becomes JavaScript, then make the rendered script use the CDATA wrapping demonstrated in the expected HTML. Done means expressions containing < produce well-formed HTML.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- coffeescript, javascript, ruby
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100