Scrimmage / karma-slim-preprocessor

Compiles slim to html for karma tests
MIT License
5 stars 6 forks source link

Add support for command-line options #3

Closed sh19910711 closed 9 years ago

sh19910711 commented 9 years ago

In the changes, I've added config.slimrbOption, because it's possible to pass data via command-line from slim v3.0.2:

$ echo 'p Hello, #{name}!!' > hello.slim
$ slimrb --locals '{"name": "Bob"}' hello.slim
<p>Hello, Bob!!</p>

We can configure it as below:

// karma.conf.js
module.exports = function(config) {
  var slimData = {
    'name': 'Bob'
  };

  config.set({
    preprocessors: {
      '**/*.slim': ['slim']
    },

    slimPreprocessor: {
      slimrbOption: "-l " + JSON.stringify(slimData)
    },

    files: [ 'hello.slim' ]
  });
};

See also: https://github.com/slim-template/slim/blob/166831c0cad5c74305c756e107e326df0d4cbb7d/CHANGES#L3

ratbeard commented 9 years ago

Looks good, thanks for the PR :star: Do you mind adding this option in the code example in the README?

sh19910711 commented 9 years ago

@ratbeard Thanks for taking the time to review. Yes I do, but it's up to you to decide whether to add the example.