gpt4 book ai didi

html - Symfony 和 RequireJS - 如何提供静态 html 文件?

转载 作者:行者123 更新时间:2023-11-28 03:15:11 25 4
gpt4 key购买 nike

RequireJS 文本插件 ( https://github.com/requirejs/text ) 需要扩展名为 .html 的文件。看来.html要求不能改。

我的 html 文件位于我的 Symfony 项目的 web 文件夹中。

使用默认配置,不可能使用 Symfony 提供任何静态 html 文件。

RequireJS 正在对模板发出 GET 请求,但未返回 html 内容。

是否有任何已知的解决方法?

最佳答案

最后,我将后端 (Symfony) 与前端完全分离。

现在,我只渲染 symfony base.html.twig(我在所有页面上使用的主要 twig 模板)以导入包含网站所有模板的 requirejs 文件。

模板以纯 html 开发,然后通过使用 Gulp 转换为 .txt。它们都捆绑在 requirejs 的 .js 文件中。

gulp.task('devTemplates', ['cleanDevTemplates'], function () {
gulp.src(srcPaths.devTemplates) // The folder which contains the templates

.pipe(minifyHtml())
.pipe(rename({suffix: '', extname: '.txt'}))
.pipe(gulp.dest(destPaths.devTemplates))

.pipe(notify({ message: 'devTemplates task complete' }));

});

关于html - Symfony 和 RequireJS - 如何提供静态 html 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28484309/

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