-
Notifications
You must be signed in to change notification settings - Fork 14
/
bootstrap3-conversion
45 lines (32 loc) · 1.61 KB
/
bootstrap3-conversion
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#CLI's
## Change control-group class to form-group
find . -name '*.tt' | xargs perl -pi -e 's/control-group/form-group/g;'
## Change span\d to col-sm-\d
find . -name '*.tt' | xargs perl -pi -e 's/class="span(\d+)/class="col-sm-$1/g;'
## Give submit buttons a default class of btn-primary
find . -name '*.tt' | xargs perl -pi -e 's/class="btn"/class="btn btn-primary"/g;'
## hidden input types need a class
find . -name '*.tt' | xargs perl -pi -e 's/type="hidden"/class="form-control" type="hidden"/g unless /class=/;'
#Manual's
## All pages with custom headers and footers should include the main header and footer to
## reduce copy/paste includes.
See var/init/views/account/{header,footer}_include.tt.
## form controls and input wrappers need individual width controls, for example
:1,$s/\<controls/col-sm-8
:1,$s/control-label/col-sm-4 control-label/
##Shortcuts
## Copy over /data/Wing/var/init/views/account/{footer,header}_include.tt /data/MyProject/views/account
## Restore any project customizations to the nav for account
##Handlebars
#Change the template script include
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.min.js" type="text/javascript"></script>
#Convert the type on all templates
<script id="user_template" type="text/x-handlebars-template">
:1,$s/text="text\/html"/type="text\/x-handlebars-template"/
#Fix the template syntax
:'<,'>perldo s/\$\{(\w+)}/{{$1}}/g;
#Compile and cache the template inside a script tag
<script type="text/javascript">
var template = Handlebars.compile($('#user_template').html());
#Update the template usage line:
$('#users').append(template(data.result));