久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      <tfoot id='WsJA2'></tfoot>
    1. <small id='WsJA2'></small><noframes id='WsJA2'>

      <i id='WsJA2'><tr id='WsJA2'><dt id='WsJA2'><q id='WsJA2'><span id='WsJA2'><b id='WsJA2'><form id='WsJA2'><ins id='WsJA2'></ins><ul id='WsJA2'></ul><sub id='WsJA2'></sub></form><legend id='WsJA2'></legend><bdo id='WsJA2'><pre id='WsJA2'><center id='WsJA2'></center></pre></bdo></b><th id='WsJA2'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='WsJA2'><tfoot id='WsJA2'></tfoot><dl id='WsJA2'><fieldset id='WsJA2'></fieldset></dl></div>
        <bdo id='WsJA2'></bdo><ul id='WsJA2'></ul>
      <legend id='WsJA2'><style id='WsJA2'><dir id='WsJA2'><q id='WsJA2'></q></dir></style></legend>

    2. 將html模板文件合并為一個JS文件

      combine html template files into one JS file(將html模板文件合并為一個JS文件)

      • <i id='5GA78'><tr id='5GA78'><dt id='5GA78'><q id='5GA78'><span id='5GA78'><b id='5GA78'><form id='5GA78'><ins id='5GA78'></ins><ul id='5GA78'></ul><sub id='5GA78'></sub></form><legend id='5GA78'></legend><bdo id='5GA78'><pre id='5GA78'><center id='5GA78'></center></pre></bdo></b><th id='5GA78'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='5GA78'><tfoot id='5GA78'></tfoot><dl id='5GA78'><fieldset id='5GA78'></fieldset></dl></div>
          <bdo id='5GA78'></bdo><ul id='5GA78'></ul>

          <small id='5GA78'></small><noframes id='5GA78'>

            <tbody id='5GA78'></tbody>

        • <tfoot id='5GA78'></tfoot>

              <legend id='5GA78'><style id='5GA78'><dir id='5GA78'><q id='5GA78'></q></dir></style></legend>
                本文介紹了將html模板文件合并為一個JS文件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..
                1. 我有 HTML 模板文件(下劃線模板語法)
                2. 這些文件以 HTML 格式保存,因此易于編輯(IDE 語法突出顯示)
                3. 我不想用 ajax 來獲取它們,而是將它們全部組合起來,并將它們包含為 js 文件.
                4. 使用 GULP 作為我的任務運行器,我希望它以某種方式結合所有 將 HTML 轉換成這樣的內容,作為一個 javascript 文件,我可以將其包含在我的 BUILD 過程中:
                1. I have HTML template files (underscore template syntax)
                2. These files are saved in HTML format so they would be easy to edit (IDE syntax highlight)
                3. I don't want to fetch them with ajax, but rather combine them all and include them as ajs file.
                4. Using GULP as my task-runner, I would like it to somehow combine all the HTML to something like this, as a javascript file that I could include in my BUILD process:

                template_file_name 是 HTML 文件名.

                template_file_name is the HTML file name.

                var templates = {
                   template_file_name : '...template HTML string...',
                   template_file_name2 : '...template HTML string...',
                   template_file_name3 : '...template HTML string...'
                }
                

                我真的不知道如何解決這個問題,以及如何從所有文件中創建這樣的文本.是的,我可以將每個單獨的文件轉換為字符串,但我怎樣才能將它放入對象中?

                I don't really know how to approach this, and how to create such text from all the files..yes I can convert each individual file to a string, but how can I put it inside an object?

                對于那些希望您的模板作為 ES6 模塊的人,我創建了 gulp-file-contents-to-modules

                For those who want your templates as ES6 modules, I have created gulp-file-contents-to-modules

                export var file_name = "This is bar.";
                export var file_name2 = "This is foo.
                ";
                export var my-folder__file_name = "This is baz.
                ";
                


                我所有與使用 gulp 組合模板文件相關的 NPM 包:

                1. https://www.npmjs.com/package/gulp-file-contents-to-keys
                2. https://www.npmjs.com/package/gulp-file-contents-to-modules
                3. https://www.npmjs.com/package/gulp-template-compile-es6

                推薦答案

                我發現這個很棒的工具可以滿足我的需求:

                I've found this wonderful tool which does exactly what I want:

                https://www.npmjs.org/package/gulp-模板編譯

                gulp.task('templates', function () {
                    gulp.src('./views/templates/**/*.html')
                        .pipe(template()) // converts html to JS
                        .pipe(concat('templates.js'))
                        .pipe(gulp.dest('./js/dist/'))
                });
                

                然后您可以使用 window.JST 訪問鍵/值對象.值是函數(我不知道為什么,但就是這樣)

                Then you can access the key/value object with window.JST. The values are functions (I don't know why, but it's like that)

                我決定使用 gulp-file-contents-to-json 這是從文件內容生成 JSON 的最簡單的方法.

                I've decided to use use gulp-file-contents-to-json which is the most simple thing possible for generating JSON from files' contents.

                我創建了 3 個 NPM 包(可能對某人很方便):

                I've created 3 NPM packages (might be handy to someone):

                1. https://www.npmjs.com/package/gulp-file-contents-to-keys
                2. https://www.npmjs.com/package/gulp-file-contents-to-modules
                3. https://www.npmjs.com/package/gulp-template-compile-es6

                這篇關于將html模板文件合并為一個JS文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                Browserify, Babel 6, Gulp - Unexpected token on spread operator(Browserify,Babel 6,Gulp - 傳播運算符上的意外令牌)
                Is it possible to pass a flag to Gulp to have it run tasks in different ways?(是否可以將標志傳遞給 Gulp 以使其以不同的方式運行任務?)
                Why do we need to install gulp globally and locally?(為什么我們需要在全局和本地安裝 gulp?)
                How to run Gulp tasks sequentially one after the other(如何一個接一個地依次運行 Gulp 任務)
                Stylesheet not loaded because of MIME-type(由于 MIME 類型而未加載樣式表)
                Visual Studio 2015 crashes when opening Javascript files(打開 Javascript 文件時 Visual Studio 2015 崩潰)

                • <tfoot id='QbTVL'></tfoot>
                  • <bdo id='QbTVL'></bdo><ul id='QbTVL'></ul>

                          <small id='QbTVL'></small><noframes id='QbTVL'>

                          <legend id='QbTVL'><style id='QbTVL'><dir id='QbTVL'><q id='QbTVL'></q></dir></style></legend>
                            <tbody id='QbTVL'></tbody>
                          <i id='QbTVL'><tr id='QbTVL'><dt id='QbTVL'><q id='QbTVL'><span id='QbTVL'><b id='QbTVL'><form id='QbTVL'><ins id='QbTVL'></ins><ul id='QbTVL'></ul><sub id='QbTVL'></sub></form><legend id='QbTVL'></legend><bdo id='QbTVL'><pre id='QbTVL'><center id='QbTVL'></center></pre></bdo></b><th id='QbTVL'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='QbTVL'><tfoot id='QbTVL'></tfoot><dl id='QbTVL'><fieldset id='QbTVL'></fieldset></dl></div>
                          主站蜘蛛池模板: 精品一区二区三区91 | 日韩成人免费 | 精品一区二区在线观看 | 国产精品欧美一区二区三区 | 精品国产91 | 男女视频在线观看网站 | 久久久看 | 91小视频在线 | 超碰伊人久久 | 亚洲午夜视频在线观看 | 91免费版在线观看 | 中文字幕 在线观看 | 一区二区三区免费网站 | 亚洲色图50p| 国产精品视频一区二区三区四区国 | 中文成人在线 | 麻豆国产一区二区三区四区 | 福利网站在线观看 | 99久久免费观看 | 毛片在线免费播放 | 91久操视频 | 国产精品视频网 | 免费看91 | 国产日韩精品一区二区三区 | 亚洲精品久久久久中文字幕二区 | 久久精品久久久 | 欧美在线一区二区三区 | 91亚洲国产成人精品一区二三 | 国产激情91久久精品导航 | 国产一级淫片免费视频 | 国产一区二区电影 | www.国产一区 | 99影视 | 日本黄色一级片视频 | 国产精品久久久久久吹潮 | 五月综合激情网 | 中文字幕亚洲精品 | www.com久久久 | 91精品国产91久久久久久吃药 | 国产激情| 91在线观看视频 |