htmlからTypeScriptへ変換するGruntタスクです
本プログラムはBerndWesselsさんが作成したgrunt-html2tsをフォークして作成しています。
https://github.com/BerndWessels https://github.com/BerndWessels/grunt-html2ts
This plugin requires Grunt.
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-as-html2ts --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-as-html2ts');
In your project's Gruntfile, add a section named ashtml2ts
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
ashtml2ts: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
},
},
})
Type: String
Default value: null
A string that is truncated from the start of the generated typescript module namespace.
Type: String
Default value: null
A string that is truncated from the start of the generated output path when the htmlOutDir option is specified.
Type: String
Default value: null
If specified the typescript will be generated starting in this directory.
Type: Boolean
Default value: false
If true all the generated typescript will be in the output directory rather than in a copy of the original directory hierarchy.
In this example, all html files matching test/app/**/*.html
will be transformed into typescript files with a copy of the original directory hierarchy into the test/.out
directory.
grunt.initConfig({
ashtml2ts: {
default: {
options: {
truncateNamespace: 'test',
truncateDir: 'test/app',
htmlOutDir: 'test/.out',
flatten: false
},
files: {
options: ['test/app/**/*.html']
}
}
},
})
ファイル毎にnamespaceやmodule名を指定する場合は、gruntのfile機能を使用して以下のように指定します。
grunt.initConfig({
ashtml2ts: {
default: {
options: {
truncateNamespace: 'test',
truncateDir: 'test/app',
htmlOutDir: 'test/.out',
flatten: false
},
files: [
{
src: 'test/sample.html',
options: {
namespace: "aaa/bbb",
propertyName: "ccc"
}
}
]
}
},
})
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
(Nothing yet)
Copyright (c) 2015 Bernd Wessels. Licensed under the MIT license.