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

Handlebars: support block names with dashes (or other special characters) #587

Merged
merged 1 commit into from
Jun 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/prism-handlebars.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function(Prism) {

var handlebars_pattern = /\{\{\{[\w\W]+?\}\}\}|\{\{[\w\W]+?\}\}/g;

Prism.languages.handlebars = Prism.languages.extend('markup', {
'handlebars': {
pattern: handlebars_pattern,
Expand All @@ -14,7 +14,7 @@
'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,
'boolean': /\b(true|false)\b/,
'block': {
pattern: /^(\s*~?\s*)[#\/]\w+/i,
pattern: /^(\s*~?\s*)[#\/]\S+/i,
lookbehind: true,
alias: 'keyword'
},
Expand Down
2 changes: 1 addition & 1 deletion components/prism-handlebars.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions examples/prism-handlebars.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ <h2>Block helpers</h2>
{{/with}}
&lt;div class="{{#if test}}foo{{else}}bar{{/if}}">&lt;/div>
{{#list array}}
{{@index}}. {{title}}
{{/list}}</code></pre>
{{@index}}. {{title}}
{{/list}}
{{#block-with-hyphens args=yep}}
This should probably work...
{{/block-with-hyphens}}
</code></pre>

<h2>Known failures</h2>
<p>There are certain edge cases where Prism will fail.
Expand All @@ -37,4 +41,4 @@ <h2>Known failures</h2>
</p>

<h3>Handlebars tag in the middle of an HTML tag</h3>
<pre><code>&lt;div{{#if test}} class="test"{{/if}}>&lt;/div></code></pre>
<pre><code>&lt;div{{#if test}} class="test"{{/if}}>&lt;/div></code></pre>