久久久久久久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模板文件合并為一個(gè)JS文件

      combine html template files into one JS file(將html模板文件合并為一個(gè)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模板文件合并為一個(gè)JS文件的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                限時(shí)送ChatGPT賬號..
                1. 我有 HTML 模板文件(下劃線模板語法)
                2. 這些文件以 HTML 格式保存,因此易于編輯(IDE 語法突出顯示)
                3. 我不想用 ajax 來獲取它們,而是將它們?nèi)拷M合起來,并將它們包含為 js 文件.
                4. 使用 GULP 作為我的任務(wù)運(yùn)行器,我希望它以某種方式結(jié)合所有 將 HTML 轉(zhuǎn)換成這樣的內(nèi)容,作為一個(gè) 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...'
                }
                

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

                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 模塊的人,我創(chuàng)建了 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 組合模板文件相關(guān)的 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

                推薦答案

                我發(fā)現(xiàn)這個(gè)很棒的工具可以滿足我的需求:

                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 訪問鍵/值對象.值是函數(shù)(我不知道為什么,但就是這樣)

                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 這是從文件內(nèi)容生成 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.

                我創(chuàng)建了 3 個(gè) 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

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

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

                相關(guān)文檔推薦

                Browserify, Babel 6, Gulp - Unexpected token on spread operator(Browserify,Babel 6,Gulp - 傳播運(yùn)算符上的意外令牌)
                Is it possible to pass a flag to Gulp to have it run tasks in different ways?(是否可以將標(biāo)志傳遞給 Gulp 以使其以不同的方式運(yùn)行任務(wù)?)
                Why do we need to install gulp globally and locally?(為什么我們需要在全局和本地安裝 gulp?)
                How to run Gulp tasks sequentially one after the other(如何一個(gè)接一個(gè)地依次運(yùn)行 Gulp 任務(wù))
                Stylesheet not loaded because of MIME-type(由于 MIME 類型而未加載樣式表)
                Visual Studio 2015 crashes when opening Javascript files(打開 Javascript 文件時(shí) 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>
                          主站蜘蛛池模板: 成人综合一区二区 | 视频一区中文字幕 | 国产精品久久久久久久久久尿 | 丁香五月网久久综合 | 欧美一区二区三区在线 | 亚洲免费在线观看视频 | 欧美精品在线免费观看 | 天天av网 | 久久国产精品久久 | 国产激情在线看 | 999久久久久久久久6666 | 99久久日韩精品免费热麻豆美女 | 成人免费片 | 欧美成人手机视频 | 好姑娘高清在线观看电影 | 成人免费在线小视频 | 免费黄色片在线观看 | 国产日韩一区二区三区 | 国产精品亚洲一区二区三区在线 | 日韩美女一区二区三区在线观看 | 精品国产精品国产偷麻豆 | 国产成人一区二区 | 免费看爱爱视频 | 国产亚韩 | 中文字幕在线视频精品 | 日韩av在线一区 | 91在线中文字幕 | 国产成人99久久亚洲综合精品 | www国产成人 | 爱草在线 | 成人高清网站 | 天天爽一爽 | 在线成人一区 | 久久一区二区三区四区 | 中文字幕在线视频一区二区三区 | 三级黄色片在线观看 | 免费高潮视频95在线观看网站 | 久久久久亚洲精品中文字幕 | 99re视频在线免费观看 | 日韩欧美三区 | 成人在线免费视频 |