【发布时间】:2019-03-10 03:00:49
【问题描述】:
我正在使用 pug/jade 和 gulp 数据和 gulp-merge-json。我找不到在我的 Json 中插入换行符的方法。 我试图在 json 中插入:
\n\"\\\/\b\f\r\u
没有任何作用。我设法使用 \t 获得了一个空格,但我确实需要能够使用换行符。
var data = require('gulp-data');
fs = require('fs'),
path = require('path'),
merge = require('gulp-merge-json');
var pug = require('gulp-pug');
gulp.task('pug:data', function() {
return gulp.src('assets/json/**/*.json')
.pipe(merge({
fileName: 'data.json',
edit: (json, file) => {
// Extract the filename and strip the extension
var filename = path.basename(file.path),
primaryKey = filename.replace(path.extname(filename), '');
// Set the filename as the primary key for our JSON data
var data = {};
data[primaryKey.toUpperCase()] = json;
return data;
}
}))
.pipe(gulp.dest('assets/temp'));
});
这里是哈巴狗代码:
#abouttxt.hide.block.big.centered.layer_top
| #{ABOUT[langage]}
这是名为 About.json 的 Json:
{"en": "Peace, Love, Unity and Having fun* !",
"fr": "Ecriture et Réalisation\nVina Hiridjee et David Boisseaux-Chical\n\nDirection artistique et Graphisme\nNicolas Dali\n\nConception et Développement\nRomain Malauzat
Production\nKomet Prod ...... etc"
}
【问题讨论】:
-
发布您的
.json文件 -
该代码尝试在哪里插入字符?
-
你好,我贴出了部分pug和json代码。
标签: json gulp pug line-breaks gulp-data