Skip to content

Commit

Permalink
Merge pull request #587 from apfelbox/handlebars-blocks-dashes
Browse files Browse the repository at this point in the history
Handlebars: support block names with dashes (or other special characters)
  • Loading branch information
Golmote committed Jun 12, 2015
2 parents 1707e4e + 67b89ea commit f409b13
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
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>

0 comments on commit f409b13

Please sign in to comment.