Skip to content

bradbenvenuti/template-string-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

template-string-loader

Webpack ES6 Template String Loader

Installation

npm install template-string-loader

Usage

You will need to use this with the babel loader or some other ES6 loader that supports template strings.

var template = require("babel!template-string!./file.html")({data: '123'});

Example template:

<!-- file.html -->
<div>${scope.data}</div>

The loader returns a function like below. Call the function with the data you want to pass to the template. That data is available on the scope param:

module.exports = function(scope){
    return `<div>${scope.data}</div>`;
}

Result:

<div>123</div>

About

Webpack ES6 Template String Loader

Resources

Stars

Watchers

Forks

Packages

No packages published