2

RequireJS 文本插件 ( https://github.com/requirejs/text ) 需要带有.html扩展名的文件。似乎.html无法更改要求。

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

在默认配置下,无法使用 Symfony 提供任何静态 html 文件。

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

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

4

1 回答 1

0

最后,我将后端(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' }));

});

于 2016-01-09T17:50:51.387 回答