git @ Cat's Eye Technologies Lexeduct / 4ef74f9
Small script which generates the in-browser version of filters. Chris Pressey 6 years ago
5 changed file(s) with 31 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
0 demo/lexeduct-browser.js
0 syntax: glob
1
2 demo/lexeduct-browser.js
99 </header>
1010
1111 </body>
12 <script src="lexeduct-browser.js"></script>
1213 <script>
13 /* TODO: do this in a much better way */
14 var module = {};
15 </script>
16 <script src="../src/filter/upper.js"></script>
17 <script>
18 var f = module.exports.filter;
14 var f = makeFilter['upper']({});
1915 alert(f('hi thEre'));
2016 </script>
0 #!/bin/sh
1
2 cd src
3 ./gen-lexeduct-browser.py >../demo/lexeduct-browser.js
0 #!/usr/bin/env python
1
2 # Written in Python right now, but should be converted to node for consistency.
3
4 import os
5
6 def main():
7 print "module = {};"
8 print "makeFilter = {};"
9 for filename in os.listdir('filter'):
10 if not filename.endswith('.js'):
11 continue
12 filter_name = filename[:-3]
13 print
14 with open(os.path.join('filter', filename), 'r') as f:
15 print f.read()
16 print "makeFilter['%s'] = module.exports.makeFilter;" % filter_name
17
18
19 if __name__ == '__main__':
20 main()