Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

silverfin/slim-lang-loader

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

slim-lang-loader

This is a webpack loader to transform slim files into HTML, and then load that HTML into Javascript. This is "true blue" slim, using the ruby program's CLI executable.

The resulting HTML does not have any boiler added - it can be full HTML documents or just partials / fragments.

The code here is a modified version of coffee-loader.

howto

  1. Make sure the slim gem is installed and there is a slimrb executable available.

  2. Install this into your project: npm install --save slim-lang-loader (or yarn add -D slim-lang-loader)

  3. Add hook to webpack.config.js (make sure to put this above any loader that expects javascript or coffeescript input):

    {test: /\.slim$/, loader: ['slim-lang-loader']},

    Also, add .slim to the list of extensions:

    resolve: {
      extensions: ['.js", <etc>, ".slim"]
    },
  4. load templates from javascript:

     var file = require("html-loader!./test.slim");
     alert(file); // this will be a html string that auto-reloads 

slim options

You can pass Slim options to slimrb using following syntax:

loader: [
  {
    loader: 'slim-lang-loader',
    options: {
      slimOptions: {
        'disable_escape': true
      }
    }
  }
]

About

Webpack loader: slim => html => javascript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%