Skip to content

Commit

Permalink
npm-liquid 测试
Browse files Browse the repository at this point in the history
  • Loading branch information
Vivomo committed Oct 30, 2020
1 parent b96fab1 commit 2aea741
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 3 additions & 1 deletion build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@
"rollup-plugin-node-resolve": "3.4.0",
"webpack": "4.24.0"
},
"dependencies": {}
"dependencies": {
"liquid": "^5.1.0"
}
}
12 changes: 12 additions & 0 deletions build/test/liquid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const Liquid = require('liquid')
const engine = new Liquid.Engine()

engine
.parse(`
{% assign l = name | split:',' %}
{% for i in l %}
{{i}}
{% endfor %}
`)
.then(template => template.render({ name: '1,2,3' }))
.then(result => console.log(result))
4 changes: 2 additions & 2 deletions build/transformHTML.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const path = require('path');
const fs = require('fs');

const {getFilesByPath} = require('../nodejs/util/fileUtil');
const {parseScript, parseBodyData, parseViewport, parseCSS, createBlog} = require('./utils');
const {parseScript, parseBodyData, parseViewport, parseCSS, createBlog, parseContent} = require('./utils');

const { JSDOM } = jsdom;

Expand All @@ -26,7 +26,7 @@ htmlPaths.forEach((htmlPath) => {
layout: bodyData.layout,
viewport: parseViewport(document),
title: document.title,
content: document.body.innerHTML,
content: parseContent(document.body.innerHTML),
};

let targetPath = path.join(__dirname, outputPath, bodyData.date + '-' + path.basename(htmlPath));
Expand Down

0 comments on commit 2aea741

Please sign in to comment.