gpt4 book ai didi

javascript - 将 haml 文件转换为 html 时复制整个文件夹结构(使用 grunt)

转载 作者:行者123 更新时间:2023-12-02 18:36:50 26 4
gpt4 key购买 nike

我正在使用 yeoman 和 grunt 并尝试将 haml 文件转换为 html 文件。我所有的 .haml 文件都位于 /app/source 内,我希望所有 html 文件都低一级,位于 /app 内。转换单个文件工作正常,这是我在“Gruntfile.js”中使用的代码

    files: {
'<%= yeoman.app %>/tester.html': '<%= yeoman.app %>/source/tester.haml',
}

但我不想单独列出每个文件,所以我尝试了类似的方法,但它不起作用:

    files: grunt.file.expandMapping(['<%= yeoman.app %>/source/*.haml'], '<%= yeoman.app %>/source/', {
rename: function(base, path) {
return base + path.replace(/.haml$/, '.html');
}
})

此代码可能也不适用于 /source 内的任何子目录。那么,我应该如何做到这一点有什么想法吗?

最佳答案

快速回答:Building the files object dynamically

进一步说明:

expand: true;                    //Enable options below
cwd: '<%= yeoman.app %>/source'; //Current working directory
src: '**/*.haml'; //All files under cwd, including sub-directories
dest: '<%= yeoman.app %>'; //Destination path prefix
ext: '.html'; //Replace file's extension name
flatten: false; //KEEP folder structure

使用这段代码替换您原来的"file"属性 GL。

关于javascript - 将 haml 文件转换为 html 时复制整个文件夹结构(使用 grunt),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17240564/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com