typesheet
A utility to generate strongly typed dicitonary of the css selectors available in html files
> typesheet --help
usage: typesheet [options] [files or globs]
--init -i run initial pass on all matched files, default: false
--output -o output directory, default: '.'
--filterRegex -f class name filter matches are kept , default: '.*' i.e. all classes
[files or globs] files or glob pattern to watch, default : **/*.(cshtml|html)
glob reference:
https://github.com/isaacs/node-glob
Example
index.html
<div id="container">
<div class="row">
<div class="col-md-4">
<h2>Heading</h2>
<p><a class="btn btn-default" href="#" role="button">View details »</a></p>
</div>
<div class="col-md-4">
<h2>Heading</h2>
<p><a class="btn btn-default" href="#" role="button">View details »</a></p>
</div>
<div class="col-md-4">
<h2>Heading</h2>
<p><a class="btn btn-default" href="#" role="button">View details »</a></p>
</div>
</div>
running typesheet
> node typesheet.js -i -o typings index.html
Waiting for changes in: index.html
TypeSheet Ready: typings/index.ts
typings/index.ts
namespace TypeSheet.index {
export const btn : string = ".btn";
export const btnPrimary : string = ".btn-primary";
export const btnLg : string = ".btn-lg";
export const containerId : string = "#container";
export const jumbotron : string = ".jumbotron";
export const btnDefault : string = ".btn-default";
export const colMd4 : string = ".col-md-4";
export const row : string = ".row";
export const noJs : string = ".no-js";
}
VS Code Autocomplete Example
License
MIT