{"id":20557,"library":"slim-lang-loader","title":"slim-lang-loader","description":"Webpack loader that transforms Slim template files into HTML strings embedded in JavaScript. Version 0.0.9 (latest as of 2019) wraps the Ruby `slimrb` CLI, meaning it requires Ruby and the Slim gem installed globally. Unlike other Slim-to-HTML converters, this is a true Ruby-based conversion, preserving full Slim feature support (e.g., inline Ruby, Slim options). The loader outputs HTML that can be used as string templates or passed to further loaders (e.g., html-loader). Last updated in 2019; no active development, but functional for projects already using Ruby Slim.","status":"maintenance","version":"0.0.9","language":"javascript","source_language":"en","source_url":"https://github.com/maxpleaner/slim-lang-loader","tags":["javascript","webpack","slim-lang","slim"],"install":[{"cmd":"npm install slim-lang-loader","lang":"bash","label":"npm"},{"cmd":"yarn add slim-lang-loader","lang":"bash","label":"yarn"},{"cmd":"pnpm add slim-lang-loader","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"loader interface required","package":"webpack","optional":false},{"reason":"runs slimrb CLI executable to convert Slim to HTML","package":"ruby","optional":false},{"reason":"provides slimrb executable","package":"slim gem","optional":false}],"imports":[{"note":"Loader outputs raw HTML string; typically used with html-loader to export the string as a module.","wrong":"const html = require('./file.slim') // without html-loader, file content is just HTML string, not a module","symbol":"default","correct":"import html from 'html-loader!./file.slim'"},{"note":"Webpack config: use the rule object with 'use' array for clarity. Must be placed before loaders that expect JS or other compiled output.","wrong":"{ test: /\\.slim$/, loader: 'slim-lang-loader' } // legacy syntax, also works but string form is deprecated in webpack 4+","symbol":"slim-lang-loader","correct":"{ test: /\\.slim$/, use: ['slim-lang-loader'] }"},{"note":"Slim options must be wrapped in a 'slimOptions' object per the loader's API.","wrong":"options: { 'disable_escape': true } // missing 'slimOptions' wrapper","symbol":"options","correct":"const config = { module: { rules: [ { test: /\\.slim$/, use: [ { loader: 'slim-lang-loader', options: { slimOptions: { disable_escape: true } } } ] } ] } }"}],"quickstart":{"code":"// webpack.config.js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.slim$/,\n        use: [\n          'slim-lang-loader'\n        ]\n      }\n    ]\n  },\n  resolve: {\n    extensions: ['.js', '.slim']\n  }\n};\n\n// template.slim\ndoctype html\nhtml\n  head\n    title Example\n  body\n    h1 Hello from Slim!\n\n// app.js\nimport html from './template.slim';\ndocument.body.innerHTML = html;","lang":"javascript","description":"Configures webpack to process .slim files via slim-lang-loader, then imports a Slim template as an HTML string."},"warnings":[{"fix":"Install Ruby and run 'gem install slim' before building.","message":"Requires Ruby and slim gem installed globally; not a pure Node.js solution.","severity":"gotcha","affected_versions":"all"},{"fix":"Use a cache-loader or only for limited use. Consider alternative Slim-to-HTML loaders that are JS-only.","message":"Loader spawns a child process to run slimrb, which can be slow for many files.","severity":"gotcha","affected_versions":"all"},{"fix":"Chain with html-loader or manually wrap the output in module.exports.","message":"Output is raw HTML string; must be used with another loader (e.g., html-loader) to be importable as a module.","severity":"gotcha","affected_versions":"all"},{"fix":"Use webpack's cache-loader or external caching.","message":"No built-in cache; re-runs slimrb on every build.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Install Ruby and run 'gem install slim'. Verify 'which slimrb' works.","cause":"Ruby or slim gem not installed, or slimrb not in PATH.","error":"Error: spawn slimrb ENOENT"},{"fix":"Add { test: /\\.slim$/, use: ['slim-lang-loader'] } to webpack config.","cause":"Slim file processed without slim-lang-loader or misconfigured rule.","error":"Module parse failed: Unexpected token (1:0)\nYou may need an appropriate loader to handle this file type."},{"fix":"Use 'html-loader' after slim-lang-loader, or wrap the require/import to handle a string.","cause":"Loaded from .slim file returns HTML string but code expects a module export.","error":"Invalid or unexpected token"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}