1

我正在使用 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"
}
4

1 回答 1

1

我没有很好地阅读哈巴狗的文档,我的错。你可以像这样进行非转义字符串插值。

!{ABOUT[langage]}
于 2018-10-05T20:44:19.527 回答