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

标签 html apache symfony requirejs requirejs-text

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/

相关文章:

javascript - 在没有内联 Javascript 的情况下显示/隐藏元素

javascript - 转换表单编号字段值结构

php - 为什么 Apache 没有在 XAMPP 上启动

apache - 尝试在 apache2 中将 http 重定向到 https

symfony - 如何在 Symfony 中配置 http_basic 防火墙以在响应正文中返回 JSON?

html - 使用 CSS 创建抽象

html - 我需要在右上角显示我的 Logo ,并且需要在导航栏中显示我的其他列表元素

php - 使用 .htaccess 隐藏目录和文件结构的存在

symfony - 使用 Sonata Admin 更新以编程方式创建的对象的 ACL

symfony - 将依赖项注入(inject)实体存储库