Navigation Menu

Skip to content

Commit

Permalink
closes riot#1998
Browse files Browse the repository at this point in the history
  • Loading branch information
prateekbh committed Sep 27, 2016
1 parent 0df48e0 commit dd86621
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/server/index.js
Expand Up @@ -12,9 +12,11 @@ riot.parsers = compiler.parsers
// allow to require('some.tag')
require.extensions['.tag'] = function(module, filename) {
var src = riot.compile(require('fs').readFileSync(filename, 'utf8'))
var preTag = src.substring(0, src.indexOf('riot.tag'))
var tagDefinitaion = src.substring(src.indexOf('riot.tag'))
module._compile(
'var riot = require(process.env.RIOT || "riot/riot.js");module.exports =' + src
, filename)
'var riot = require(process.env.RIOT || "riot/riot.js");' + preTag + ';module.exports =' + tagDefinitaion
, filename)
}

// simple-dom helper
Expand Down
3 changes: 3 additions & 0 deletions test/importedtag/imported-tag.tag
@@ -0,0 +1,3 @@
<imported-tag>
<span>I am imported</span>
</imported-tag>
5 changes: 5 additions & 0 deletions test/specs/server/node.js
Expand Up @@ -121,4 +121,9 @@ describe('Node/io.js', function() {
expect($('textarea[name="txta2"]').val()).to.be('')
})

it('render subsequent tags, when required from parent tag', function() {
var tag = riot.render('import-tag')
expect(tag).to.be('<import-tag><imported-tag><span>I am imported</span></imported-tag></import-tag>')
})

})
5 changes: 5 additions & 0 deletions test/tag/import-tag.tag
@@ -0,0 +1,5 @@
var importedTag = require('../importedtag/imported-tag.tag');
<import-tag>
<imported-tag>
</imported-tag>
</import-tag>

0 comments on commit dd86621

Please sign in to comment.