Skip to content

Commit

Permalink
Allow inner DOM elements to be defined in modules
Browse files Browse the repository at this point in the history
  • Loading branch information
gwagroves committed May 6, 2016
1 parent 864042c commit d19a755
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "grunt-moduledoc",
"description": "Creates a frontend module documentation",
"version": "0.3.1",
"version": "0.4.0",
"homepage": "https://github.com/gwa/grunt-moduledoc",
"author": {
"name": "Timothy Groves",
Expand Down
21 changes: 20 additions & 1 deletion tasks/FileParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,26 @@ FileParser.prototype.parse = function() {
}
);

return parseContains(data);
data = parseDOM(data);
data = parseContains(data);

return data;
}

function parseDOM(data) {
var dom = data.dom, arr;

if (!dom) {
data.dom = 'div';
return data;
}

arr = data.dom.split('>');

data.dom = arr[0];
data.dom_inner = arr[1] ? arr[1] : null;

return data;
}

function parseContains(data) {
Expand Down
4 changes: 2 additions & 2 deletions templates/module.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
{{#if module.description}}
<div class="description">{{module.description}}</div>
{{/if}}
<pre><code class="language-markup">&lt;{{module.dom}} class=&quot;{{module.class}}&quot;&gt;
...
<pre><code class="language-markup">&lt;{{module.dom}}{{#if module.class}} class=&quot;{{module.class}}&quot;{{/if}}&gt;
{{#if module.dom_inner}}&lt;{{module.dom_inner}}&gt;...&lt;/{{module.dom_inner}}&gt;{{else}}...{{/if}}
&lt;/{{module.dom}}&gt;</code></pre>

{{#if module.options.length}}
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/docs/button.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
title: BUTTON
class: ui-button
dom: a
dom: a>span
contains:
- text

0 comments on commit d19a755

Please sign in to comment.