Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

metalsmith-jstransformer

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metalsmith-jstransformer - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

41

index.js
var minimatch = require('minimatch');
var jstransformer = require('jstransformer');
var path = require('path');
var merge = require('merge');
function plugin (opts) {
module.exports = function (opts) {
var transformers = {};
var mix = function(obj1, obj2) {
var newObj = {};
var key;
for (key in obj1) {
if (obj1.hasOwnProperty(key)) {
newObj[key] = obj1[key];
}
}
for (key in obj2) {
if (obj2.hasOwnProperty(key)) {
newObj[key] = obj2[key];
}
}
return newObj;
};
// Load all the required JSTransformers.

@@ -32,15 +17,9 @@ for (var i in opts || {}) {

for (var transform in transformers) {
// Find all files that can be handled by the given transform.
// TODO: Use .inputFormats().
var process = Object.keys(files).filter(
minimatch.filter('*.' + transform, {
matchBase: true
})
);
// Loop through each transformable file.
for (var file in process) {
var filename = process[file];
// Find all files that match the given transformer.
var transformFiles = minimatch.match(Object.keys(files), "*." + transform);
for (var i in transformFiles) {
var filename = transformFiles[i];
var data = files[filename];
var locals = mix(data, metalsmith.metadata());
var locals = merge(data, metalsmith.metadata());

@@ -56,3 +35,3 @@ // Construct the new file name.

// Process the file contents using the transformer.
var result = transformers[transform].render(data.contents, locals);
var result = transformers[transform].render(data.contents.toString('utf-8'), locals);
data.contents = new Buffer(result.body);

@@ -68,4 +47,2 @@

}
}
module.exports = plugin;
};
{
"name": "metalsmith-jstransformer",
"version": "0.0.1",
"version": "0.0.2",
"description": "Metalsmith JSTransformer Plugin",

@@ -26,11 +26,13 @@ "main": "index.js",

"dependencies": {
"jstransformer": "~0.0.2",
"jstransformer": "^0.0.2",
"merge": "^1.2.0",
"minimatch": "^2.0.4"
},
"devDependencies": {
"jstransformer-jade": "~0.0.3",
"assert-dir-equal": "*",
"metalsmith": "^1.5.0",
"jstransformer-jade": "*",
"jstransformer-styl": "^0.1.0",
"metalsmith": "^1.7.0",
"mocha": "*"
}
}

@@ -18,2 +18,6 @@ # Metalsmith JSTransformer Plugin

First, create a file that you would like to act on with JSTransformers, with
the file name of "example.html.<pluginname>". In the following Jade example, it
would be `example.html.jade`.
### CLI

@@ -43,3 +47,3 @@

metalsmith.use(jstransformer([
'jade'
"jade"
]));

@@ -53,3 +57,3 @@ ```

```javascript
['jade', 'scss']
["jade", "scss"]
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc