2016-07-05 8 views
0

で挿入HTMLのための一口を使用して、htmlファイルの内容に変数this._template = "include:'Views/Dialog.html'";を置き換える私が使用一口をしたい私は2つのファイルを持っているjsの

(function (Controllers) { 
    var DialogElement = (function() { 
     function DialogElement() { 
      this._template = "include:'Views/Dialog.html'"; 
     } 
     return DialogElement; 
    }()); 
    Controllers.DialogElement = DialogElement; 
})(Controllers)); 

とhtml

<div>Simple dialog!</div> 

をJS。

ので、取得するには:

function DialogElement() { 
    this._template = "<div>Simple dialog!</div>"; 
} 

は、これに適したプラグインがあることができますか?

答えて

0

gulp-html2jsgulp-injectを学習しましたが、期待通りに動作しません。

だから私はあなたのsalf packageを作り、としてそれを使用する:

gulp.task('inject', function() { 
    gulp 
     .src('Controllers/*.js') 
     .pipe(inject('Views/*.html')) 
     .pipe(gulp.dest('build')); 
}); 

とchengeコントローラ:

this._template = "{{load path='Views/Dialog.html'}}" 
関連する問題