Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ middleware: [require('connect-modrewrite')([
}]
```

#### CLI

```shell
npx ssi /tmp/test/index.shtml /tmp/output/index.html
```

### Methods

#### parse(filename, contents)
Expand Down
14 changes: 14 additions & 0 deletions bin/ssi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env node

const fs = require("fs");
const { dirname } = require("path");

const ssi = require("..");

const [_node, _file, input, output] = process.argv;

const parser = new ssi(dirname(input), dirname(output), "*.shtml", true);

const { contents } = parser.parse(input, fs.readFileSync(input, "utf-8"));

fs.writeFileSync(output, contents);
3 changes: 3 additions & 0 deletions lib/DirectiveHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,16 @@ module.exports = (function() {
return {error: "Endif while not inside of If block"};
}

var parser = this.parser;

for (var i = 0; i < this.conditionals.length; i++) {
var conditional = this.conditionals[i];
var variables = {};

// Find the first conditional that is true
if (this._parseExpression(conditional.getExpression()).truthy) {
var directiveHandler = new DirectiveHandler(this.ioUtils, this.directiveRegex);
directiveHandler.parser = parser;
var output = {output: "", variables: {}};

// Iterate over the directives contained by the conditional, and parse them
Expand Down
Loading