summaryrefslogtreecommitdiff
path: root/standalone/no-th/haskell-patches/yesod-form_spliced-TH.patch
blob: b9a84b1adda71d06eba9a17be0f65e24a7d0deed (plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
From 4cf9a045569ea0b51b4ee11df2dadbde330f7813 Mon Sep 17 00:00:00 2001
From: dummy <dummy@example.com>
Date: Fri, 3 Jul 2015 01:06:34 +0000
Subject: [PATCH] hack TH

1. EvilSplicer
2. Add imports
3. Fix some syntax errors in spliced code
4. Remove some persistent stuff that doesn't build.
---
 Yesod/Form/Bootstrap3.hs | 189 +++++++++--
 Yesod/Form/Fields.hs     | 811 ++++++++++++++++++++++++++++++++++++-----------
 Yesod/Form/Functions.hs  | 255 ++++++++++++---
 Yesod/Form/Jquery.hs     | 124 ++++++--
 Yesod/Form/MassInput.hs  | 226 ++++++++++---
 Yesod/Form/Nic.hs        |  60 +++-
 yesod-form.cabal         |   2 +-
 7 files changed, 1311 insertions(+), 356 deletions(-)

diff --git a/Yesod/Form/Bootstrap3.hs b/Yesod/Form/Bootstrap3.hs
index 8377a68..fa8b7d4 100644
--- a/Yesod/Form/Bootstrap3.hs
+++ b/Yesod/Form/Bootstrap3.hs
@@ -35,6 +35,9 @@ import Data.String (IsString(..))
 import Yesod.Core
 
 import qualified Data.Text as T
+import qualified Text.Hamlet
+import qualified Text.Blaze.Internal
+import qualified Data.Foldable
 
 import Yesod.Form.Types
 import Yesod.Form.Functions
@@ -155,44 +158,144 @@ renderBootstrap3 formLayout aform fragment = do
     let views = views' []
         has (Just _) = True
         has Nothing  = False
-        widget = [whamlet|
-            $newline never
-            #{fragment}
-            $forall view <- views
-              <div .form-group :fvRequired view:.required :not $ fvRequired view:.optional :has $ fvErrors view:.has-error>
-                $case formLayout
-                  $of BootstrapBasicForm
-                    $if fvId view /= bootstrapSubmitId
-                      <label for=#{fvId view}>#{fvLabel view}
-                    ^{fvInput view}
-                    ^{helpWidget view}
-                  $of BootstrapInlineForm
-                    $if fvId view /= bootstrapSubmitId
-                      <label .sr-only for=#{fvId view}>#{fvLabel view}
-                    ^{fvInput view}
-                    ^{helpWidget view}
-                  $of BootstrapHorizontalForm labelOffset labelSize inputOffset inputSize
-                    $if fvId view /= bootstrapSubmitId
-                      <label .control-label .#{toOffset labelOffset} .#{toColumn labelSize} for=#{fvId view}>#{fvLabel view}
-                      <div .#{toOffset inputOffset} .#{toColumn inputSize}>
-                        ^{fvInput view}
-                        ^{helpWidget view}
-                    $else
-                      <div .#{toOffset (addGO inputOffset (addGO labelOffset labelSize))} .#{toColumn inputSize}>
-                        ^{fvInput view}
-                        ^{helpWidget view}
-                |]
+        widget =         do { (asWidgetT . toWidget) (toHtml fragment);
+             Data.Foldable.mapM_
+               (\ view_a2d4p
+                  -> do { (asWidgetT . toWidget)
+                            ((Text.Blaze.Internal.preEscapedText . T.pack)
+                               "<div class=\"form-group ");
+                          Text.Hamlet.condH
+                            [(fvRequired view_a2d4p, 
+                              (asWidgetT . toWidget)
+                                ((Text.Blaze.Internal.preEscapedText . T.pack) "required "))]
+                            Nothing;
+                          Text.Hamlet.condH
+                            [(not (fvRequired view_a2d4p), 
+                              (asWidgetT . toWidget)
+                                ((Text.Blaze.Internal.preEscapedText . T.pack) "optional "))]
+                            Nothing;
+                          Text.Hamlet.condH
+                            [(has (fvErrors view_a2d4p), 
+                              (asWidgetT . toWidget)
+                                ((Text.Blaze.Internal.preEscapedText . T.pack) "has-error"))]
+                            Nothing;
+                          (asWidgetT . toWidget)
+                            ((Text.Blaze.Internal.preEscapedText . T.pack) "\">");
+                          case formLayout of {
+                            ; BootstrapBasicForm
+                              -> do { Text.Hamlet.condH
+                                        [((/=) (fvId view_a2d4p) bootstrapSubmitId, 
+                                          do { (asWidgetT . toWidget)
+                                                 ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                                    "<label for=\"");
+                                               (asWidgetT . toWidget) (toHtml (fvId view_a2d4p));
+                                               (asWidgetT . toWidget)
+                                                 ((Text.Blaze.Internal.preEscapedText . T.pack) "\">");
+                                               (asWidgetT . toWidget) (toHtml (fvLabel view_a2d4p));
+                                               (asWidgetT . toWidget)
+                                                 ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                                    "</label>") })]
+                                        Nothing;
+                                      (asWidgetT . toWidget) (fvInput view_a2d4p);
+                                      (asWidgetT . toWidget) (helpWidget view_a2d4p) }
+                            ; BootstrapInlineForm
+                              -> do { Text.Hamlet.condH
+                                        [((/=) (fvId view_a2d4p) bootstrapSubmitId, 
+                                          do { (asWidgetT . toWidget)
+                                                 ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                                    "<label class=\"sr-only\" for=\"");
+                                               (asWidgetT . toWidget) (toHtml (fvId view_a2d4p));
+                                               (asWidgetT . toWidget)
+                                                 ((Text.Blaze.Internal.preEscapedText . T.pack) "\">");
+                                               (asWidgetT . toWidget) (toHtml (fvLabel view_a2d4p));
+                                               (asWidgetT . toWidget)
+                                                 ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                                    "</label>") })]
+                                        Nothing;
+                                      (asWidgetT . toWidget) (fvInput view_a2d4p);
+                                      (asWidgetT . toWidget) (helpWidget view_a2d4p) }
+                            ; BootstrapHorizontalForm labelOffset_a2d4q
+                                                    labelSize_a2d4r
+                                                    inputOffset_a2d4s
+                                                    inputSize_a2d4t
+                              -> Text.Hamlet.condH
+                                   [((/=) (fvId view_a2d4p) bootstrapSubmitId, 
+                                     do { (asWidgetT . toWidget)
+                                            ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                               "<label class=\"control-label ");
+                                          (asWidgetT . toWidget) (toHtml (toOffset labelOffset_a2d4q));
+                                          (asWidgetT . toWidget)
+                                            ((Text.Blaze.Internal.preEscapedText . T.pack) " ");
+                                          (asWidgetT . toWidget) (toHtml (toColumn labelSize_a2d4r));
+                                          (asWidgetT . toWidget)
+                                            ((Text.Blaze.Internal.preEscapedText . T.pack) "\" for=\"");
+                                          (asWidgetT . toWidget) (toHtml (fvId view_a2d4p));
+                                          (asWidgetT . toWidget)
+                                            ((Text.Blaze.Internal.preEscapedText . T.pack) "\">");
+                                          (asWidgetT . toWidget) (toHtml (fvLabel view_a2d4p));
+                                          (asWidgetT . toWidget)
+                                            ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                               "</label><div class=\"");
+                                          (asWidgetT . toWidget) (toHtml (toOffset inputOffset_a2d4s));
+                                          (asWidgetT . toWidget)
+                                            ((Text.Blaze.Internal.preEscapedText . T.pack) " ");
+                                          (asWidgetT . toWidget) (toHtml (toColumn inputSize_a2d4t));
+                                          (asWidgetT . toWidget)
+                                            ((Text.Blaze.Internal.preEscapedText . T.pack) "\">");
+                                          (asWidgetT . toWidget) (fvInput view_a2d4p);
+                                          (asWidgetT . toWidget) (helpWidget view_a2d4p);
+                                          (asWidgetT . toWidget)
+                                            ((Text.Blaze.Internal.preEscapedText . T.pack) "</div>") })]
+                                   (Just
+                                      (do { (asWidgetT . toWidget)
+                                              ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                                 "<div class=\"");
+                                            (asWidgetT . toWidget)
+                                              (toHtml
+                                                 (toOffset
+                                                    (addGO
+                                                       inputOffset_a2d4s
+                                                       (addGO labelOffset_a2d4q labelSize_a2d4r))));
+                                            (asWidgetT . toWidget)
+                                              ((Text.Blaze.Internal.preEscapedText . T.pack) " ");
+                                            (asWidgetT . toWidget) (toHtml (toColumn inputSize_a2d4t));
+                                            (asWidgetT . toWidget)
+                                              ((Text.Blaze.Internal.preEscapedText . T.pack) "\">");
+                                            (asWidgetT . toWidget) (fvInput view_a2d4p);
+                                            (asWidgetT . toWidget) (helpWidget view_a2d4p);
+                                            (asWidgetT . toWidget)
+                                              ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                                 "</div>") })) };
+                          (asWidgetT . toWidget)
+                            ((Text.Blaze.Internal.preEscapedText . T.pack) "</div>") })
+               views }
+
     return (res, widget)
 
 
 -- | (Internal) Render a help widget for tooltips and errors.
 helpWidget :: FieldView site -> WidgetT site IO ()
-helpWidget view = [whamlet|
-    $maybe tt <- fvTooltip view
-      <span .help-block>#{tt}
-    $maybe err <- fvErrors view
-      <span .help-block>#{err}
-|]
+helpWidget view = do { Text.Hamlet.maybeH
+       (fvTooltip view)
+       (\ tt_a2d5x
+          -> do { (asWidgetT . toWidget)
+                    ((Text.Blaze.Internal.preEscapedText . T.pack)
+                       "<span class=\"help-block\">");
+                  (asWidgetT . toWidget) (toHtml tt_a2d5x);
+                  (asWidgetT . toWidget)
+                    ((Text.Blaze.Internal.preEscapedText . T.pack) "</span>") })
+       Nothing;
+     Text.Hamlet.maybeH
+       (fvErrors view)
+       (\ err_a2d5y
+          -> do { (asWidgetT . toWidget)
+                    ((Text.Blaze.Internal.preEscapedText . T.pack)
+                       "<span class=\"help-block\">");
+                  (asWidgetT . toWidget) (toHtml err_a2d5y);
+                  (asWidgetT . toWidget)
+                    ((Text.Blaze.Internal.preEscapedText . T.pack) "</span>") })
+       Nothing }
+
 
 
 -- | How the 'bootstrapSubmit' button should be rendered.
@@ -247,7 +350,23 @@ mbootstrapSubmit
     => BootstrapSubmit msg -> MForm m (FormResult (), FieldView site)
 mbootstrapSubmit (BootstrapSubmit msg classes attrs) =
     let res = FormSuccess ()
-        widget = [whamlet|<button class="btn #{classes}" type=submit *{attrs}>_{msg}|]
+        widget =         do { (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . T.pack)
+                  "<button class=\"btn ");
+             (asWidgetT . toWidget) (toHtml classes);
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . T.pack)
+                  "\" type=\"submit\"");
+             (asWidgetT . toWidget)
+               ((Text.Hamlet.attrsToHtml . Text.Hamlet.toAttributes) attrs);
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . T.pack) ">");
+             ((liftM (toHtml .) getMessageRender)
+              >>=
+                (\ urender_a2d6f -> (asWidgetT . toWidget) (urender_a2d6f msg)));
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . T.pack) "</button>") }
+
         fv  = FieldView { fvLabel    = ""
                         , fvTooltip  = Nothing
                         , fvId       = bootstrapSubmitId
@@ -314,4 +433,4 @@ bootstrapSubmitId = "b:ootstrap___unique__:::::::::::::::::submit-id"
 -- >        <$> areq textField nameSettings Nothing
 -- >      where nameSettings = withAutofocus $
 -- >                           withPlaceholder "First name" $
--- >                           (bfs ("Name" :: Text))
\ No newline at end of file
+-- >                           (bfs ("Name" :: Text))
diff --git a/Yesod/Form/Fields.hs b/Yesod/Form/Fields.hs
index 5fe123e..42fd7d6 100644
--- a/Yesod/Form/Fields.hs
+++ b/Yesod/Form/Fields.hs
@@ -52,8 +52,6 @@ module Yesod.Form.Fields
     , Option (..)
     , OptionList (..)
     , mkOptionList
-    , optionsPersist
-    , optionsPersistKey
     , optionsPairs
     , optionsEnum
     ) where
@@ -80,6 +78,15 @@ import Control.Monad (when, unless)
 import Data.Either (partitionEithers)
 import Data.Maybe (listToMaybe, fromMaybe)
 
+import qualified Text.Blaze as Text.Blaze.Internal
+import qualified Text.Blaze.Internal
+import qualified Text.Hamlet
+import qualified Yesod.Core.Widget
+import qualified Text.Css
+import qualified Data.Monoid
+import qualified Data.Foldable
+import qualified Control.Monad
+
 import qualified Blaze.ByteString.Builder.Html.Utf8 as B
 import Blaze.ByteString.Builder (writeByteString, toLazyByteString)
 import Blaze.ByteString.Builder.Internal.Write (fromWriteList)
@@ -102,8 +109,6 @@ import Control.Applicative ((<$>), (<|>))
 
 import Data.Attoparsec.Text (Parser, char, string, digit, skipSpace, endOfInput, parseOnly)
 
-import Yesod.Persist.Core
-
 defaultFormMessage :: FormMessage -> Text
 defaultFormMessage = englishFormMessage
 
@@ -115,10 +120,25 @@ intField = Field
             Right (a, "") -> Right a
             _ -> Left $ MsgInvalidInteger s
 
-    , fieldView = \theId name attrs val isReq -> toWidget [hamlet|
-$newline never
-<input id="#{theId}" name="#{name}" *{attrs} type="number" step=1 :isReq:required="" value="#{showVal val}">
-|]
+    , fieldView = \theId name attrs val isReq -> toWidget  $     \ _render_a2nCq
+      -> do { id
+                ((Text.Blaze.Internal.preEscapedText . pack) "<input id=\"");
+              id (toHtml theId);
+              id ((Text.Blaze.Internal.preEscapedText . pack) "\" name=\"");
+              id (toHtml name);
+              id
+                ((Text.Blaze.Internal.preEscapedText . pack)
+                   "\" type=\"number\" step=\"1\"");
+              condH
+                [(isReq, 
+                  id ((Text.Blaze.Internal.preEscapedText . pack) " required=\"\""))]
+                Nothing;
+              id ((Text.Blaze.Internal.preEscapedText . pack) " value=\"");
+              id (toHtml (showVal val));
+              id ((Text.Blaze.Internal.preEscapedText . pack) "\"");
+              id ((attrsToHtml . toAttributes) attrs);
+              id ((Text.Blaze.Internal.preEscapedText . pack) ">") }
+
     , fieldEnctype = UrlEncoded
     }
   where
@@ -133,10 +153,25 @@ doubleField = Field
             Right (a, "") -> Right a
             _ -> Left $ MsgInvalidNumber s
 
-    , fieldView = \theId name attrs val isReq -> toWidget [hamlet|
-$newline never
-<input id="#{theId}" name="#{name}" *{attrs} type="number" step=any :isReq:required="" value="#{showVal val}">
-|]
+    , fieldView = \theId name attrs val isReq -> toWidget  $     \ _render_a2nCV
+      -> do { id
+                ((Text.Blaze.Internal.preEscapedText . pack) "<input id=\"");
+              id (toHtml theId);
+              id ((Text.Blaze.Internal.preEscapedText . pack) "\" name=\"");
+              id (toHtml name);
+              id
+                ((Text.Blaze.Internal.preEscapedText . pack)
+                   "\" type=\"number\" step=\"any\"");
+              condH
+                [(isReq, 
+                  id ((Text.Blaze.Internal.preEscapedText . pack) " required=\"\""))]
+                Nothing;
+              id ((Text.Blaze.Internal.preEscapedText . pack) " value=\"");
+              id (toHtml (showVal val));
+              id ((Text.Blaze.Internal.preEscapedText . pack) "\"");
+              id ((attrsToHtml . toAttributes) attrs);
+              id ((Text.Blaze.Internal.preEscapedText . pack) ">") }
+
     , fieldEnctype = UrlEncoded
     }
   where showVal = either id (pack . show)
@@ -147,10 +182,24 @@ $newline never
 dayField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m Day
 dayField = Field
     { fieldParse = parseHelper $ parseDate . unpack
-    , fieldView = \theId name attrs val isReq -> toWidget [hamlet|
-$newline never
-<input id="#{theId}" name="#{name}" *{attrs} type="date" :isReq:required="" value="#{showVal val}">
-|]
+    , fieldView = \theId name attrs val isReq -> toWidget  $     \ _render_a2nDh
+      -> do { id
+                ((Text.Blaze.Internal.preEscapedText . pack) "<input id=\"");
+              id (toHtml theId);
+              id ((Text.Blaze.Internal.preEscapedText . pack) "\" name=\"");
+              id (toHtml name);
+              id
+                ((Text.Blaze.Internal.preEscapedText . pack) "\" type=\"date\"");
+              condH
+                [(isReq, 
+                  id ((Text.Blaze.Internal.preEscapedText . pack) " required=\"\""))]
+                Nothing;
+              id ((Text.Blaze.Internal.preEscapedText . pack) " value=\"");
+              id (toHtml (showVal val));
+              id ((Text.Blaze.Internal.preEscapedText . pack) "\"");
+              id ((attrsToHtml . toAttributes) attrs);
+              id ((Text.Blaze.Internal.preEscapedText . pack) ">") }
+
     , fieldEnctype = UrlEncoded
     }
   where showVal = either id (pack . show)
@@ -179,10 +228,25 @@ timeFieldTypeText = timeFieldOfType "text"
 timeFieldOfType :: Monad m => RenderMessage (HandlerSite m) FormMessage => Text -> Field m TimeOfDay
 timeFieldOfType inputType = Field
     { fieldParse = parseHelper parseTime
-    , fieldView = \theId name attrs val isReq -> toWidget [hamlet|
-$newline never
-<input id="#{theId}" name="#{name}" *{attrs} type="#{inputType}" :isReq:required="" value="#{showVal val}">
-|]
+    , fieldView = \theId name attrs val isReq -> toWidget  $     \ _render_a2nDN
+      -> do { id
+                ((Text.Blaze.Internal.preEscapedText . pack) "<input id=\"");
+              id (toHtml theId);
+              id ((Text.Blaze.Internal.preEscapedText . pack) "\" name=\"");
+              id (toHtml name);
+              id ((Text.Blaze.Internal.preEscapedText . pack) "\" type=\"");
+              id (toHtml inputType);
+              id ((Text.Blaze.Internal.preEscapedText . pack) "\"");
+              condH
+                [(isReq, 
+                  id ((Text.Blaze.Internal.preEscapedText . pack) " required=\"\""))]
+                Nothing;
+              id ((Text.Blaze.Internal.preEscapedText . pack) " value=\"");
+              id (toHtml (showVal val));
+              id ((Text.Blaze.Internal.preEscapedText . pack) "\"");
+              id ((attrsToHtml . toAttributes) attrs);
+              id ((Text.Blaze.Internal.preEscapedText . pack) ">") }
+
     , fieldEnctype = UrlEncoded
     }
   where
@@ -196,10 +260,23 @@ $newline never
 htmlField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m Html
 htmlField = Field
     { fieldParse = parseHelper $ Right . preEscapedText . sanitizeBalance
-    , fieldView = \theId name attrs val isReq -> toWidget [hamlet|
-$newline never
-<textarea :isReq:required="" id="#{theId}" name="#{name}" *{attrs}>#{showVal val}
-|]
+    , fieldView = \theId name attrs val isReq -> toWidget  $     \ _render_a2nEc
+      -> do { id
+                ((Text.Blaze.Internal.preEscapedText . pack) "<textarea");
+              condH
+                [(isReq, 
+                  id ((Text.Blaze.Internal.preEscapedText . pack) " required=\"\""))]
+                Nothing;
+              id ((Text.Blaze.Internal.preEscapedText . pack) " id=\"");
+              id (toHtml theId);
+              id ((Text.Blaze.Internal.preEscapedText . pack) "\" name=\"");
+              id (toHtml name);
+              id ((Text.Blaze.Internal.preEscapedText . pack) "\"");
+              id ((attrsToHtml . toAttributes) attrs);
+              id ((Text.Blaze.Internal.preEscapedText . pack) ">");
+              id (toHtml (showVal val));
+              id ((Text.Blaze.Internal.preEscapedText . pack) "</textarea>") }
+
     , fieldEnctype = UrlEncoded
     }
   where showVal = either id (pack . renderHtml)
@@ -231,10 +308,22 @@ instance ToHtml Textarea where
 textareaField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m Textarea
 textareaField = Field
     { fieldParse = parseHelper $ Right . Textarea
-    , fieldView = \theId name attrs val isReq -> toWidget [hamlet|
-$newline never
-<textarea id="#{theId}" name="#{name}" :isReq:required="" *{attrs}>#{either id unTextarea val}
-|]
+    , fieldView = \theId name attrs val isReq -> toWidget  $     \ _render_a2nEL
+      -> do { id
+                ((Text.Blaze.Internal.preEscapedText . pack) "<textarea id=\"");
+              id (toHtml theId);
+              id ((Text.Blaze.Internal.preEscapedText . pack) "\" name=\"");
+              id (toHtml name);
+              id ((Text.Blaze.Internal.preEscapedText . pack) "\"");
+              condH
+                [(isReq, 
+                  id ((Text.Blaze.Internal.preEscapedText . pack) " required=\"\""))]
+                Nothing;
+              id ((attrsToHtml . toAttributes) attrs);
+              id ((Text.Blaze.Internal.preEscapedText . pack) ">");
+              id (toHtml (either id unTextarea val));
+              id ((Text.Blaze.Internal.preEscapedText . pack) "</textarea>") }
+
     , fieldEnctype = UrlEncoded
     }
 
@@ -243,10 +332,19 @@ hiddenField :: (Monad m, PathPiece p, RenderMessage (HandlerSite m) FormMessage)
             => Field m p
 hiddenField = Field
     { fieldParse = parseHelper $ maybe (Left MsgValueRequired) Right . fromPathPiece
-    , fieldView = \theId name attrs val _isReq -> toWidget [hamlet|
-$newline never
-<input type="hidden" id="#{theId}" name="#{name}" *{attrs} value="#{either id toPathPiece val}">
-|]
+    , fieldView = \theId name attrs val _isReq -> toWidget  $     \ _render_a2nFl
+      -> do { id
+                ((Text.Blaze.Internal.preEscapedText . pack)
+                   "<input type=\"hidden\" id=\"");
+              id (toHtml theId);
+              id ((Text.Blaze.Internal.preEscapedText . pack) "\" name=\"");
+              id (toHtml name);
+              id ((Text.Blaze.Internal.preEscapedText . pack) "\" value=\"");
+              id (toHtml (either id toPathPiece val));
+              id ((Text.Blaze.Internal.preEscapedText . pack) "\"");
+              id ((attrsToHtml . toAttributes) attrs);
+              id ((Text.Blaze.Internal.preEscapedText . pack) ">") }
+
     , fieldEnctype = UrlEncoded
     }
 
@@ -255,20 +353,53 @@ textField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m Tex
 textField = Field
     { fieldParse = parseHelper $ Right
     , fieldView = \theId name attrs val isReq ->
-        [whamlet|
-$newline never
-<input id="#{theId}" name="#{name}" *{attrs} type="text" :isReq:required value="#{either id id val}">
-|]
+        do { (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) "<input id=\"");
+             (asWidgetT . toWidget) (toHtml theId);
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) "\" name=\"");
+             (asWidgetT . toWidget) (toHtml name);
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) "\" type=\"text\"");
+             condH
+               [(isReq, 
+                 (asWidgetT . toWidget)
+                   ((Text.Blaze.Internal.preEscapedText . pack) " required"))]
+               Nothing;
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) " value=\"");
+             (asWidgetT . toWidget) (toHtml (either id id val));
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) "\"");
+             (asWidgetT . toWidget) ((attrsToHtml . toAttributes) attrs);
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) ">") }
+
     , fieldEnctype = UrlEncoded
     }
 -- | Creates an input with @type="password"@.
 passwordField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m Text
 passwordField = Field
     { fieldParse = parseHelper $ Right
-    , fieldView = \theId name attrs val isReq -> toWidget [hamlet|
-$newline never
-<input id="#{theId}" name="#{name}" *{attrs} type="password" :isReq:required="" value="#{either id id val}">
-|]
+    , fieldView = \theId name attrs val isReq -> toWidget  $     \ _render_a2nG7
+      -> do { id
+                ((Text.Blaze.Internal.preEscapedText . pack) "<input id=\"");
+              id (toHtml theId);
+              id ((Text.Blaze.Internal.preEscapedText . pack) "\" name=\"");
+              id (toHtml name);
+              id
+                ((Text.Blaze.Internal.preEscapedText . pack)
+                   "\" type=\"password\"");
+              condH
+                [(isReq, 
+                  id ((Text.Blaze.Internal.preEscapedText . pack) " required=\"\""))]
+                Nothing;
+              id ((Text.Blaze.Internal.preEscapedText . pack) " value=\"");
+              id (toHtml (either id id val));
+              id ((Text.Blaze.Internal.preEscapedText . pack) "\"");
+              id ((attrsToHtml . toAttributes) attrs);
+              id ((Text.Blaze.Internal.preEscapedText . pack) ">") }
+
     , fieldEnctype = UrlEncoded
     }
 
@@ -342,10 +473,24 @@ emailField = Field
             case Email.canonicalizeEmail $ encodeUtf8 s of
                 Just e -> Right $ decodeUtf8With lenientDecode e
                 Nothing -> Left $ MsgInvalidEmail s
-    , fieldView = \theId name attrs val isReq -> toWidget [hamlet|
-$newline never
-<input id="#{theId}" name="#{name}" *{attrs} type="email" :isReq:required="" value="#{either id id val}">
-|]
+    , fieldView = \theId name attrs val isReq -> toWidget  $     \ _render_a2nKu
+      -> do { id
+                ((Text.Blaze.Internal.preEscapedText . pack) "<input id=\"");
+              id (toHtml theId);
+              id ((Text.Blaze.Internal.preEscapedText . pack) "\" name=\"");
+              id (toHtml name);
+              id
+                ((Text.Blaze.Internal.preEscapedText . pack) "\" type=\"email\"");
+              condH
+                [(isReq, 
+                  id ((Text.Blaze.Internal.preEscapedText . pack) " required=\"\""))]
+                Nothing;
+              id ((Text.Blaze.Internal.preEscapedText . pack) " value=\"");
+              id (toHtml (either id id val));
+              id ((Text.Blaze.Internal.preEscapedText . pack) "\"");
+              id ((attrsToHtml . toAttributes) attrs);
+              id ((Text.Blaze.Internal.preEscapedText . pack) ">") }
+
     , fieldEnctype = UrlEncoded
     }
 
@@ -360,10 +505,25 @@ multiEmailField = Field
             in case partitionEithers addrs of
                 ([], good) -> Right good
                 (bad, _) -> Left $ MsgInvalidEmail $ cat bad
-    , fieldView = \theId name attrs val isReq -> toWidget [hamlet|
-$newline never
-<input id="#{theId}" name="#{name}" *{attrs} type="email" multiple :isReq:required="" value="#{either id cat val}">
-|]
+    , fieldView = \theId name attrs val isReq -> toWidget  $     \ _render_a2nL5
+      -> do { id
+                ((Text.Blaze.Internal.preEscapedText . pack) "<input id=\"");
+              id (toHtml theId);
+              id ((Text.Blaze.Internal.preEscapedText . pack) "\" name=\"");
+              id (toHtml name);
+              id
+                ((Text.Blaze.Internal.preEscapedText . pack)
+                   "\" type=\"email\" multiple");
+              condH
+                [(isReq, 
+                  id ((Text.Blaze.Internal.preEscapedText . pack) " required=\"\""))]
+                Nothing;
+              id ((Text.Blaze.Internal.preEscapedText . pack) " value=\"");
+              id (toHtml (either id cat val));
+              id ((Text.Blaze.Internal.preEscapedText . pack) "\"");
+              id ((attrsToHtml . toAttributes) attrs);
+              id ((Text.Blaze.Internal.preEscapedText . pack) ">") }
+
     , fieldEnctype = UrlEncoded
     }
     where
@@ -380,20 +540,74 @@ searchField :: Monad m => RenderMessage (HandlerSite m) FormMessage => AutoFocus
 searchField autoFocus = Field
     { fieldParse = parseHelper Right
     , fieldView = \theId name attrs val isReq -> do
-        [whamlet|
-$newline never
-<input id="#{theId}" name="#{name}" *{attrs} type="search" :isReq:required="" :autoFocus:autofocus="" value="#{either id id val}">
-|]
+        do { (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) "<input id=\"");
+             (asWidgetT . toWidget) (toHtml theId);
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) "\" name=\"");
+             (asWidgetT . toWidget) (toHtml name);
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) "\" type=\"search\"");
+             condH
+               [(isReq, 
+                 (asWidgetT . toWidget)
+                   ((Text.Blaze.Internal.preEscapedText . pack) " required=\"\""))]
+               Nothing;
+             condH
+               [(autoFocus, 
+                 (asWidgetT . toWidget)
+                   ((Text.Blaze.Internal.preEscapedText . pack) " autofocus=\"\""))]
+               Nothing;
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) " value=\"");
+             (asWidgetT . toWidget) (toHtml (either id id val));
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) "\"");
+             (asWidgetT . toWidget) ((attrsToHtml . toAttributes) attrs);
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) ">") }
+
         when autoFocus $ do
           -- we want this javascript to be placed immediately after the field
-          [whamlet|
-$newline never
-<script>if (!('autofocus' in document.createElement('input'))) {document.getElementById('#{theId}').focus();}
-|]
-          toWidget [cassius|
-            ##{theId}
-              -webkit-appearance: textfield
-            |]
+          do { (asWidgetT . toWidget)
+                 ((Text.Blaze.Internal.preEscapedText . pack)
+                    "<script>if (!('autofocus' in document.createElement('input'))) {document.getElementById('");
+               (asWidgetT . toWidget) (toHtml theId);
+               (asWidgetT . toWidget)
+                 ((Text.Blaze.Internal.preEscapedText . pack)
+                    "').focus();}</script>") }
+
+          toWidget  $           \ _render_a2nMA
+            -> (Text.Css.CssNoWhitespace . (foldr ($) []))
+                 [((++)
+                   $ (map
+                        Text.Css.TopBlock
+                        (((Text.Css.Block
+                             {Text.Css.blockSelector = Data.Monoid.mconcat
+                                                                           [(Text.Css.fromText
+                                                                             . Text.Css.pack)
+                                                                              "#",
+                                                                            toCss theId],
+                              Text.Css.blockAttrs = (Prelude.concat
+                                                                       $ ([Text.Css.Attr
+                                                                             (Data.Monoid.mconcat
+                                                                                [(Text.Css.fromText
+                                                                                  . Text.Css.pack)
+                                                                                   "-webkit-appearance"])
+                                                                             (Data.Monoid.mconcat
+                                                                                [(Text.Css.fromText
+                                                                                  . Text.Css.pack)
+                                                                                   "textfield"])]
+                                                                          :
+                                                                            (map
+                                                                               Text.Css.mixinAttrs
+                                                                               []))),
+                              Text.Css.blockBlocks = (),
+                              Text.Css.blockMixins = ()}               :)
+                          . ((foldr (.) id [])
+                             . (concatMap Text.Css.mixinBlocks [] ++)))
+                           [])))]
+
     , fieldEnctype = UrlEncoded
     }
 -- | Creates an input with @type="url"@, validating the URL according to RFC3986.
@@ -404,7 +618,28 @@ urlField = Field
             Nothing -> Left $ MsgInvalidUrl s
             Just _ -> Right s
     , fieldView = \theId name attrs val isReq ->
-        [whamlet|<input ##{theId} name=#{name} *{attrs} type=url :isReq:required value=#{either id id val}>|]
+        do { (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) "<input id=\"");
+             (asWidgetT . toWidget) (toHtml theId);
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) "\" name=\"");
+             (asWidgetT . toWidget) (toHtml name);
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) "\" type=\"url\"");
+             condH
+               [(isReq, 
+                 (asWidgetT . toWidget)
+                   ((Text.Blaze.Internal.preEscapedText . pack) " required"))]
+               Nothing;
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) " value=\"");
+             (asWidgetT . toWidget) (toHtml (either id id val));
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) "\"");
+             (asWidgetT . toWidget) ((attrsToHtml . toAttributes) attrs);
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) ">") }
+
     , fieldEnctype = UrlEncoded
     }
 
@@ -423,18 +658,54 @@ selectField :: (Eq a, RenderMessage site FormMessage)
             => HandlerT site IO (OptionList a)
             -> Field (HandlerT site IO) a
 selectField = selectFieldHelper
-    (\theId name attrs inside -> [whamlet|
-$newline never
-<select ##{theId} name=#{name} *{attrs}>^{inside}
-|]) -- outside
-    (\_theId _name isSel -> [whamlet|
-$newline never
-<option value=none :isSel:selected>_{MsgSelectNone}
-|]) -- onOpt
-    (\_theId _name _attrs value isSel text -> [whamlet|
-$newline never
-<option value=#{value} :isSel:selected>#{text}
-|]) -- inside
+    (\theId name attrs inside ->     do { (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack) "<select id=\"");
+         (asWidgetT . toWidget) (toHtml theId);
+         (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack) "\" name=\"");
+         (asWidgetT . toWidget) (toHtml name);
+         (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack) "\"");
+         (asWidgetT . toWidget) ((attrsToHtml . toAttributes) attrs);
+         (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack) ">");
+         (asWidgetT . toWidget) inside;
+         (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack) "</select>") })
+ -- outside
+    (\_theId _name isSel ->     do { (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack)
+              "<option value=\"none\"");
+         condH
+           [(isSel, 
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) " selected"))]
+           Nothing;
+         (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack) ">");
+         ((Control.Monad.liftM (toHtml .) getMessageRender)
+          >>=
+            (\ urender_a2nOk
+               -> (asWidgetT . toWidget) (urender_a2nOk MsgSelectNone)));
+         (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack) "</option>") })
+ -- onOpt
+    (\_theId _name _attrs value isSel text ->     do { (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack) "<option value=\"");
+         (asWidgetT . toWidget) (toHtml value);
+         (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack) "\"");
+         condH
+           [(isSel, 
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) " selected"))]
+           Nothing;
+         (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack) ">");
+         (asWidgetT . toWidget) (toHtml text);
+         (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack) "</option>") })
+ -- inside
 
 -- | Creates a @\<select>@ tag for selecting multiple options.
 multiSelectFieldList :: (Eq a, RenderMessage site FormMessage, RenderMessage site msg)
@@ -459,11 +730,45 @@ multiSelectField ioptlist =
     view theId name attrs val isReq = do
         opts <- fmap olOptions $ handlerToWidget ioptlist
         let selOpts = map (id &&& (optselected val)) opts
-        [whamlet|
-            <select ##{theId} name=#{name} :isReq:required multiple *{attrs}>
-                $forall (opt, optsel) <- selOpts
-                    <option value=#{optionExternalValue opt} :optsel:selected>#{optionDisplay opt}
-                |]
+        do { (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) "<select id=\"");
+             (asWidgetT . toWidget) (toHtml theId);
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) "\" name=\"");
+             (asWidgetT . toWidget) (toHtml name);
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) "\"");
+             condH
+               [(isReq, 
+                 (asWidgetT . toWidget)
+                   ((Text.Blaze.Internal.preEscapedText . pack) " required"))]
+               Nothing;
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) " multiple");
+             (asWidgetT . toWidget) ((attrsToHtml . toAttributes) attrs);
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) ">");
+             Data.Foldable.mapM_
+               (\ (opt_a2nPy, optsel_a2nPz)
+                  -> do { (asWidgetT . toWidget)
+                            ((Text.Blaze.Internal.preEscapedText . pack) "<option value=\"");
+                          (asWidgetT . toWidget) (toHtml (optionExternalValue opt_a2nPy));
+                          (asWidgetT . toWidget)
+                            ((Text.Blaze.Internal.preEscapedText . pack) "\"");
+                          condH
+                            [(optsel_a2nPz, 
+                              (asWidgetT . toWidget)
+                                ((Text.Blaze.Internal.preEscapedText . pack) " selected"))]
+                            Nothing;
+                          (asWidgetT . toWidget)
+                            ((Text.Blaze.Internal.preEscapedText . pack) ">");
+                          (asWidgetT . toWidget) (toHtml (optionDisplay opt_a2nPy));
+                          (asWidgetT . toWidget)
+                            ((Text.Blaze.Internal.preEscapedText . pack) "</option>") })
+               selOpts;
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) "</select>") }
+
         where
             optselected (Left _) _ = False
             optselected (Right vals) opt = (optionInternalValue opt) `elem` vals
@@ -489,37 +794,115 @@ checkboxesField ioptlist = (multiSelectField ioptlist)
             opts <- fmap olOptions $ handlerToWidget ioptlist
             let optselected (Left _) _ = False
                 optselected (Right vals) opt = (optionInternalValue opt) `elem` vals
-            [whamlet|
-                <span ##{theId}>
-                    $forall opt <- opts
-                        <label>
-                            <input type=checkbox name=#{name} value=#{optionExternalValue opt} *{attrs} :optselected val opt:checked>
-                            #{optionDisplay opt}
-                |]
+            do { (asWidgetT . toWidget)
+                   ((Text.Blaze.Internal.preEscapedText . pack) "<span id=\"");
+                 (asWidgetT . toWidget) (toHtml theId);
+                 (asWidgetT . toWidget)
+                   ((Text.Blaze.Internal.preEscapedText . pack) "\">");
+                 Data.Foldable.mapM_
+                   (\ opt_a2nQo
+                      -> do { (asWidgetT . toWidget)
+                                ((Text.Blaze.Internal.preEscapedText . pack)
+                                   "<label><input type=\"checkbox\" name=\"");
+                              (asWidgetT . toWidget) (toHtml name);
+                              (asWidgetT . toWidget)
+                                ((Text.Blaze.Internal.preEscapedText . pack) "\" value=\"");
+                              (asWidgetT . toWidget) (toHtml (optionExternalValue opt_a2nQo));
+                              (asWidgetT . toWidget)
+                                ((Text.Blaze.Internal.preEscapedText . pack) "\"");
+                              condH
+                                [(optselected val opt_a2nQo, 
+                                  (asWidgetT . toWidget)
+                                    ((Text.Blaze.Internal.preEscapedText . pack) " checked"))]
+                                Nothing;
+                              (asWidgetT . toWidget) ((attrsToHtml . toAttributes) attrs);
+                              (asWidgetT . toWidget)
+                                ((Text.Blaze.Internal.preEscapedText . pack) ">");
+                              (asWidgetT . toWidget) (toHtml (optionDisplay opt_a2nQo));
+                              (asWidgetT . toWidget)
+                                ((Text.Blaze.Internal.preEscapedText . pack) "</label>") })
+                   opts;
+                 (asWidgetT . toWidget)
+                   ((Text.Blaze.Internal.preEscapedText . pack) "</span>") }
+
     }
 -- | Creates an input with @type="radio"@ for selecting one option.
 radioField :: (Eq a, RenderMessage site FormMessage)
            => HandlerT site IO (OptionList a)
            -> Field (HandlerT site IO) a
 radioField = selectFieldHelper
-    (\theId _name _attrs inside -> [whamlet|
-$newline never
-<div ##{theId}>^{inside}
-|])
-    (\theId name isSel -> [whamlet|
-$newline never
-<label .radio for=#{theId}-none>
-    <div>
-        <input id=#{theId}-none type=radio name=#{name} value=none :isSel:checked>
-        _{MsgSelectNone}
-|])
-    (\theId name attrs value isSel text -> [whamlet|
-$newline never
-<label .radio for=#{theId}-#{value}>
-    <div>
-        <input id=#{theId}-#{value} type=radio name=#{name} value=#{value} :isSel:checked *{attrs}>
-        \#{text}
-|])
+    (\theId _name _attrs inside ->     do { (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack) "<div id=\"");
+         (asWidgetT . toWidget) (toHtml theId);
+         (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack) "\">");
+         (asWidgetT . toWidget) inside;
+         (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack) "</div>") })
+
+    (\theId name isSel ->     do { (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack)
+              "<label class=\"radio\" for=\"");
+         (asWidgetT . toWidget) (toHtml theId);
+         (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack)
+              "-none\"><div><input id=\"");
+         (asWidgetT . toWidget) (toHtml theId);
+         (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack)
+              "-none\" type=\"radio\" name=\"");
+         (asWidgetT . toWidget) (toHtml name);
+         (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack) "\" value=\"none\"");
+         condH
+           [(isSel, 
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) " checked"))]
+           Nothing;
+         (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack) ">");
+         ((Control.Monad.liftM (toHtml .) getMessageRender)
+          >>=
+            (\ urender_a2nR7
+               -> (asWidgetT . toWidget) (urender_a2nR7 MsgSelectNone)));
+         (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack) "</div></label>") })
+
+    (\theId name attrs value isSel text ->     do { (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack)
+              "<label class=\"radio\" for=\"");
+         (asWidgetT . toWidget) (toHtml theId);
+         (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack) "-");
+         (asWidgetT . toWidget) (toHtml value);
+         (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack)
+              "\"><div><input id=\"");
+         (asWidgetT . toWidget) (toHtml theId);
+         (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack) "-");
+         (asWidgetT . toWidget) (toHtml value);
+         (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack)
+              "\" type=\"radio\" name=\"");
+         (asWidgetT . toWidget) (toHtml name);
+         (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack) "\" value=\"");
+         (asWidgetT . toWidget) (toHtml value);
+         (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack) "\"");
+         condH
+           [(isSel, 
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) " checked"))]
+           Nothing;
+         (asWidgetT . toWidget) ((attrsToHtml . toAttributes) attrs);
+         (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack) ">");
+         (asWidgetT . toWidget) (toHtml text);
+         (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack) "</div></label>") })
+
 
 -- | Creates a group of radio buttons to answer the question given in the message. Radio buttons are used to allow differentiating between an empty response (@Nothing@) and a no response (@Just False@). Consider using the simpler 'checkBoxField' if you don't need to make this distinction.
 --
@@ -531,19 +914,83 @@ $newline never
 boolField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m Bool
 boolField = Field
       { fieldParse = \e _ -> return $ boolParser e
-      , fieldView = \theId name attrs val isReq -> [whamlet|
-$newline never
-  $if not isReq
-      <input id=#{theId}-none *{attrs} type=radio name=#{name} value=none checked>
-      <label for=#{theId}-none>_{MsgSelectNone}
-
-
-<input id=#{theId}-yes *{attrs} type=radio name=#{name} value=yes :showVal id val:checked>
-<label for=#{theId}-yes>_{MsgBoolYes}
+      , fieldView = \theId name attrs val isReq ->       do { condH
+             [(not isReq, 
+               do { (asWidgetT . toWidget)
+                      ((Text.Blaze.Internal.preEscapedText . pack) "<input id=\"");
+                    (asWidgetT . toWidget) (toHtml theId);
+                    (asWidgetT . toWidget)
+                      ((Text.Blaze.Internal.preEscapedText . pack)
+                         "-none\" type=\"radio\" name=\"");
+                    (asWidgetT . toWidget) (toHtml name);
+                    (asWidgetT . toWidget)
+                      ((Text.Blaze.Internal.preEscapedText . pack)
+                         "\" value=\"none\" checked");
+                    (asWidgetT . toWidget) ((attrsToHtml . toAttributes) attrs);
+                    (asWidgetT . toWidget)
+                      ((Text.Blaze.Internal.preEscapedText . pack) "><label for=\"");
+                    (asWidgetT . toWidget) (toHtml theId);
+                    (asWidgetT . toWidget)
+                      ((Text.Blaze.Internal.preEscapedText . pack) "-none\">");
+                    ((Control.Monad.liftM (toHtml .) getMessageRender)
+                     >>=
+                       (\ urender_a2nSk
+                          -> (asWidgetT . toWidget) (urender_a2nSk MsgSelectNone)));
+                    (asWidgetT . toWidget)
+                      ((Text.Blaze.Internal.preEscapedText . pack) "</label>") })]
+             Nothing;
+           (asWidgetT . toWidget)
+             ((Text.Blaze.Internal.preEscapedText . pack) "<input id=\"");
+           (asWidgetT . toWidget) (toHtml theId);
+           (asWidgetT . toWidget)
+             ((Text.Blaze.Internal.preEscapedText . pack)
+                "-yes\" type=\"radio\" name=\"");
+           (asWidgetT . toWidget) (toHtml name);
+           (asWidgetT . toWidget)
+             ((Text.Blaze.Internal.preEscapedText . pack) "\" value=\"yes\"");
+           condH
+             [(showVal id val, 
+               (asWidgetT . toWidget)
+                 ((Text.Blaze.Internal.preEscapedText . pack) " checked"))]
+             Nothing;
+           (asWidgetT . toWidget) ((attrsToHtml . toAttributes) attrs);
+           (asWidgetT . toWidget)
+             ((Text.Blaze.Internal.preEscapedText . pack) "><label for=\"");
+           (asWidgetT . toWidget) (toHtml theId);
+           (asWidgetT . toWidget)
+             ((Text.Blaze.Internal.preEscapedText . pack) "-yes\">");
+           ((Control.Monad.liftM (toHtml .) getMessageRender)
+            >>=
+              (\ urender_a2nSl
+                 -> (asWidgetT . toWidget) (urender_a2nSl MsgBoolYes)));
+           (asWidgetT . toWidget)
+             ((Text.Blaze.Internal.preEscapedText . pack)
+                "</label><input id=\"");
+           (asWidgetT . toWidget) (toHtml theId);
+           (asWidgetT . toWidget)
+             ((Text.Blaze.Internal.preEscapedText . pack)
+                "-no\" type=\"radio\" name=\"");
+           (asWidgetT . toWidget) (toHtml name);
+           (asWidgetT . toWidget)
+             ((Text.Blaze.Internal.preEscapedText . pack) "\" value=\"no\"");
+           condH
+             [(showVal not val, 
+               (asWidgetT . toWidget)
+                 ((Text.Blaze.Internal.preEscapedText . pack) " checked"))]
+             Nothing;
+           (asWidgetT . toWidget) ((attrsToHtml . toAttributes) attrs);
+           (asWidgetT . toWidget)
+             ((Text.Blaze.Internal.preEscapedText . pack) "><label for=\"");
+           (asWidgetT . toWidget) (toHtml theId);
+           (asWidgetT . toWidget)
+             ((Text.Blaze.Internal.preEscapedText . pack) "-no\">");
+           ((Control.Monad.liftM (toHtml .) getMessageRender)
+            >>=
+              (\ urender_a2nSm
+                 -> (asWidgetT . toWidget) (urender_a2nSm MsgBoolNo)));
+           (asWidgetT . toWidget)
+             ((Text.Blaze.Internal.preEscapedText . pack) "</label>") }
 
-<input id=#{theId}-no *{attrs} type=radio name=#{name} value=no :showVal not val:checked>
-<label for=#{theId}-no>_{MsgBoolNo}
-|]
     , fieldEnctype = UrlEncoded
     }
   where
@@ -570,10 +1017,24 @@ $newline never
 checkBoxField :: Monad m => RenderMessage (HandlerSite m) FormMessage => Field m Bool
 checkBoxField = Field
     { fieldParse = \e _ -> return $ checkBoxParser e
-    , fieldView  = \theId name attrs val _ -> [whamlet|
-$newline never
-<input id=#{theId} *{attrs} type=checkbox name=#{name} value=yes :showVal id val:checked>
-|]
+    , fieldView  = \theId name attrs val _ ->     do { (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack) "<input id=\"");
+         (asWidgetT . toWidget) (toHtml theId);
+         (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack)
+              "\" type=\"checkbox\" name=\"");
+         (asWidgetT . toWidget) (toHtml name);
+         (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack) "\" value=\"yes\"");
+         condH
+           [(showVal id val, 
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . pack) " checked"))]
+           Nothing;
+         (asWidgetT . toWidget) ((attrsToHtml . toAttributes) attrs);
+         (asWidgetT . toWidget)
+           ((Text.Blaze.Internal.preEscapedText . pack) ">") }
+
     , fieldEnctype = UrlEncoded
     }
 
@@ -619,66 +1080,6 @@ optionsPairs opts = do
 optionsEnum :: (MonadHandler m, Show a, Enum a, Bounded a) => m (OptionList a)
 optionsEnum = optionsPairs $ map (\x -> (pack $ show x, x)) [minBound..maxBound]
 
--- | Selects a list of 'Entity's with the given 'Filter' and 'SelectOpt's. The @(a -> msg)@ function is then used to derive the display value for an 'OptionList'. Example usage:
---
--- > Country
--- >    name Text
--- >    deriving Eq -- Must derive Eq
---
--- > data CountryForm = CountryForm
--- >   { country :: Entity Country
--- >   }
--- >
--- > countryNameForm :: AForm Handler CountryForm
--- > countryNameForm = CountryForm
--- >         <$> areq (selectField countries) "Which country do you live in?" Nothing
--- >         where
--- >           countries = optionsPersist [] [Asc CountryName] countryName
-optionsPersist :: ( YesodPersist site, PersistEntity a
-                  , PersistQuery (PersistEntityBackend a)
-                  , PathPiece (Key a)
-                  , RenderMessage site msg
-                  , YesodPersistBackend site ~ PersistEntityBackend a
-                  )
-               => [Filter a]
-               -> [SelectOpt a]
-               -> (a -> msg)
-               -> HandlerT site IO (OptionList (Entity a))
-optionsPersist filts ords toDisplay = fmap mkOptionList $ do
-    mr <- getMessageRender
-    pairs <- runDB $ selectList filts ords
-    return $ map (\(Entity key value) -> Option
-        { optionDisplay = mr (toDisplay value)
-        , optionInternalValue = Entity key value
-        , optionExternalValue = toPathPiece key
-        }) pairs
-
--- | An alternative to 'optionsPersist' which returns just the 'Key' instead of
--- the entire 'Entity'.
---
--- Since 1.3.2
-optionsPersistKey
-  :: (YesodPersist site
-     , PersistEntity a
-     , PersistQuery (PersistEntityBackend a)
-     , PathPiece (Key a)
-     , RenderMessage site msg
-     , YesodPersistBackend site ~ PersistEntityBackend a
-     )
-  => [Filter a]
-  -> [SelectOpt a]
-  -> (a -> msg)
-  -> HandlerT site IO (OptionList (Key a))
-
-optionsPersistKey filts ords toDisplay = fmap mkOptionList $ do
-    mr <- getMessageRender
-    pairs <- runDB $ selectList filts ords
-    return $ map (\(Entity key value) -> Option
-        { optionDisplay = mr (toDisplay value)
-        , optionInternalValue = key
-        , optionExternalValue = toPathPiece key
-        }) pairs
-
 selectFieldHelper
         :: (Eq a, RenderMessage site FormMessage)
         => (Text -> Text -> [(Text, Text)] -> WidgetT site IO () -> WidgetT site IO ())
@@ -722,9 +1123,21 @@ fileField = Field
         case files of
             [] -> Right Nothing
             file:_ -> Right $ Just file
-    , fieldView = \id' name attrs _ isReq -> toWidget [hamlet|
-            <input id=#{id'} name=#{name} *{attrs} type=file :isReq:required>
-        |]
+    , fieldView = \id' name attrs _ isReq -> toWidget  $     \ _render_a2nUV
+      -> do { id
+                ((Text.Blaze.Internal.preEscapedText . pack) "<input id=\"");
+              id (toHtml id');
+              id ((Text.Blaze.Internal.preEscapedText . pack) "\" name=\"");
+              id (toHtml name);
+              id
+                ((Text.Blaze.Internal.preEscapedText . pack) "\" type=\"file\"");
+              condH
+                [(isReq, 
+                  id ((Text.Blaze.Internal.preEscapedText . pack) " required"))]
+                Nothing;
+              id ((attrsToHtml . toAttributes) attrs);
+              id ((Text.Blaze.Internal.preEscapedText . pack) ">") }
+
     , fieldEnctype = Multipart
     }
 
@@ -751,10 +1164,19 @@ fileAFormReq fs = AForm $ \(site, langs) menvs ints -> do
             { fvLabel = toHtml $ renderMessage site langs $ fsLabel fs
             , fvTooltip = fmap (toHtml . renderMessage site langs) $ fsTooltip fs
             , fvId = id'
-            , fvInput = [whamlet|
-$newline never
-<input type=file name=#{name} ##{id'} *{fsAttrs fs}>
-|]
+            , fvInput =             do { (asWidgetT . toWidget)
+                   ((Text.Blaze.Internal.preEscapedText . pack)
+                      "<input type=\"file\" name=\"");
+                 (asWidgetT . toWidget) (toHtml name);
+                 (asWidgetT . toWidget)
+                   ((Text.Blaze.Internal.preEscapedText . pack) "\" id=\"");
+                 (asWidgetT . toWidget) (toHtml id');
+                 (asWidgetT . toWidget)
+                   ((Text.Blaze.Internal.preEscapedText . pack) "\"");
+                 (asWidgetT . toWidget) ((attrsToHtml . toAttributes) (fsAttrs fs));
+                 (asWidgetT . toWidget)
+                   ((Text.Blaze.Internal.preEscapedText . pack) ">") }
+
             , fvErrors = errs
             , fvRequired = True
             }
@@ -783,10 +1205,19 @@ fileAFormOpt fs = AForm $ \(master, langs) menvs ints -> do
             { fvLabel = toHtml $ renderMessage master langs $ fsLabel fs
             , fvTooltip = fmap (toHtml . renderMessage master langs) $ fsTooltip fs
             , fvId = id'
-            , fvInput = [whamlet|
-$newline never
-<input type=file name=#{name} ##{id'} *{fsAttrs fs}>
-|]
+            , fvInput =             do { (asWidgetT . toWidget)
+                   ((Text.Blaze.Internal.preEscapedText . pack)
+                      "<input type=\"file\" name=\"");
+                 (asWidgetT . toWidget) (toHtml name);
+                 (asWidgetT . toWidget)
+                   ((Text.Blaze.Internal.preEscapedText . pack) "\" id=\"");
+                 (asWidgetT . toWidget) (toHtml id');
+                 (asWidgetT . toWidget)
+                   ((Text.Blaze.Internal.preEscapedText . pack) "\"");
+                 (asWidgetT . toWidget) ((attrsToHtml . toAttributes) (fsAttrs fs));
+                 (asWidgetT . toWidget)
+                   ((Text.Blaze.Internal.preEscapedText . pack) ">") }
+
             , fvErrors = errs
             , fvRequired = False
             }
diff --git a/Yesod/Form/Functions.hs b/Yesod/Form/Functions.hs
index 0d83b79..61e9b66 100644
--- a/Yesod/Form/Functions.hs
+++ b/Yesod/Form/Functions.hs
@@ -60,12 +60,14 @@ import Text.Blaze (Markup, toMarkup)
 #define toHtml toMarkup
 import Yesod.Core
 import Network.Wai (requestMethod)
-import Text.Hamlet (shamlet)
 import Data.Monoid (mempty)
 import Data.Maybe (listToMaybe, fromMaybe)
 import qualified Data.Map as Map
 import qualified Data.Text.Encoding as TE
 import Control.Arrow (first)
+import qualified Text.Hamlet
+import qualified Text.Blaze.Internal
+import qualified Data.Foldable
 
 -- | Get a unique identifier.
 newFormIdent :: Monad m => MForm m Text
@@ -217,7 +219,14 @@ postHelper form env = do
     let token =
             case reqToken req of
                 Nothing -> mempty
-                Just n -> [shamlet|<input type=hidden name=#{tokenKey} value=#{n}>|]
+                Just n ->                 do { id
+                       ((Text.Blaze.Internal.preEscapedText . pack)
+                          "<input type=\"hidden\" name=\"");
+                     id (toHtml tokenKey);
+                     id ((Text.Blaze.Internal.preEscapedText . pack) "\" value=\"");
+                     id (toHtml n);
+                     id ((Text.Blaze.Internal.preEscapedText . pack) "\">") }
+
     m <- getYesod
     langs <- languages
     ((res, xml), enctype) <- runFormGeneric (form token) m langs env
@@ -298,7 +307,12 @@ getHelper :: MonadHandler m
           -> Maybe (Env, FileEnv)
           -> m (a, Enctype)
 getHelper form env = do
-    let fragment = [shamlet|<input type=hidden name=#{getKey}>|]
+    let fragment =     do { id
+           ((Text.Blaze.Internal.preEscapedText . pack)
+              "<input type=\"hidden\" name=\"");
+         id (toHtml getKey);
+         id ((Text.Blaze.Internal.preEscapedText . pack) "\">") }
+
     langs <- languages
     m <- getYesod
     runFormGeneric (form fragment) m langs env
@@ -333,10 +347,15 @@ identifyForm
 identifyForm identVal form = \fragment -> do
     -- Create hidden <input>.
     let fragment' =
-          [shamlet|
-            <input type=hidden name=#{identifyFormKey} value=#{identVal}>
-            #{fragment}
-          |]
+          do { id
+                 ((Text.Blaze.Internal.preEscapedText . pack)
+                    "<input type=\"hidden\" name=\"");
+               id (toHtml identifyFormKey);
+               id ((Text.Blaze.Internal.preEscapedText . pack) "\" value=\"");
+               id (toHtml identVal);
+               id ((Text.Blaze.Internal.preEscapedText . pack) "\">");
+               id (toHtml fragment) }
+
 
     -- Check if we got its value back.
     mp <- askParams
@@ -366,22 +385,70 @@ renderTable, renderDivs, renderDivsNoLabels :: Monad m => FormRender m a
 renderTable aform fragment = do
     (res, views') <- aFormToForm aform
     let views = views' []
-    let widget = [whamlet|
-$newline never
-$if null views
-    \#{fragment}
-$forall (isFirst, view) <- addIsFirst views
-    <tr :fvRequired view:.required :not $ fvRequired view:.optional>
-        <td>
-            $if isFirst
-                \#{fragment}
-            <label for=#{fvId view}>#{fvLabel view}
-            $maybe tt <- fvTooltip view
-                <div .tooltip>#{tt}
-        <td>^{fvInput view}
-        $maybe err <- fvErrors view
-            <td .errors>#{err}
-|]
+    let widget =     do { Text.Hamlet.condH
+           [(null views, (asWidgetT . toWidget) (toHtml fragment))] Nothing;
+         Data.Foldable.mapM_
+           (\ (isFirst_aNqW, view_aNqX)
+              -> do { (asWidgetT . toWidget)
+                        ((Text.Blaze.Internal.preEscapedText . pack) "<tr");
+                      Text.Hamlet.condH
+                        [(or [fvRequired view_aNqX, not (fvRequired view_aNqX)], 
+                          do { (asWidgetT . toWidget)
+                                 ((Text.Blaze.Internal.preEscapedText . pack) " class=\"");
+                               Text.Hamlet.condH
+                                 [(fvRequired view_aNqX, 
+                                   (asWidgetT . toWidget)
+                                     ((Text.Blaze.Internal.preEscapedText . pack) "required "))]
+                                 Nothing;
+                               Text.Hamlet.condH
+                                 [(not (fvRequired view_aNqX), 
+                                   (asWidgetT . toWidget)
+                                     ((Text.Blaze.Internal.preEscapedText . pack) "optional"))]
+                                 Nothing;
+                               (asWidgetT . toWidget)
+                                 ((Text.Blaze.Internal.preEscapedText . pack) "\"") })]
+                        Nothing;
+                      (asWidgetT . toWidget)
+                        ((Text.Blaze.Internal.preEscapedText . pack) "><td>");
+                      Text.Hamlet.condH
+                        [(isFirst_aNqW, (asWidgetT . toWidget) (toHtml fragment))] Nothing;
+                      (asWidgetT . toWidget)
+                        ((Text.Blaze.Internal.preEscapedText . pack) "<label for=\"");
+                      (asWidgetT . toWidget) (toHtml (fvId view_aNqX));
+                      (asWidgetT . toWidget)
+                        ((Text.Blaze.Internal.preEscapedText . pack) "\">");
+                      (asWidgetT . toWidget) (toHtml (fvLabel view_aNqX));
+                      (asWidgetT . toWidget)
+                        ((Text.Blaze.Internal.preEscapedText . pack) "</label>");
+                      Text.Hamlet.maybeH
+                        (fvTooltip view_aNqX)
+                        (\ tt_aNqY
+                           -> do { (asWidgetT . toWidget)
+                                     ((Text.Blaze.Internal.preEscapedText . pack)
+                                        "<div class=\"tooltip\">");
+                                   (asWidgetT . toWidget) (toHtml tt_aNqY);
+                                   (asWidgetT . toWidget)
+                                     ((Text.Blaze.Internal.preEscapedText . pack) "</div>") })
+                        Nothing;
+                      (asWidgetT . toWidget)
+                        ((Text.Blaze.Internal.preEscapedText . pack) "</td><td>");
+                      (asWidgetT . toWidget) (fvInput view_aNqX);
+                      (asWidgetT . toWidget)
+                        ((Text.Blaze.Internal.preEscapedText . pack) "</td>");
+                      Text.Hamlet.maybeH
+                        (fvErrors view_aNqX)
+                        (\ err_aNqZ
+                           -> do { (asWidgetT . toWidget)
+                                     ((Text.Blaze.Internal.preEscapedText . pack)
+                                        "<td class=\"errors\">");
+                                   (asWidgetT . toWidget) (toHtml err_aNqZ);
+                                   (asWidgetT . toWidget)
+                                     ((Text.Blaze.Internal.preEscapedText . pack) "</td>") })
+                        Nothing;
+                      (asWidgetT . toWidget)
+                        ((Text.Blaze.Internal.preEscapedText . pack) "</tr>") })
+           (addIsFirst views) }
+
     return (res, widget)
   where
     addIsFirst [] = []
@@ -397,19 +464,66 @@ renderDivsMaybeLabels :: Monad m => Bool -> FormRender m a
 renderDivsMaybeLabels withLabels aform fragment = do
     (res, views') <- aFormToForm aform
     let views = views' []
-    let widget = [whamlet|
-$newline never
-\#{fragment}
-$forall view <- views
-    <div :fvRequired view:.required :not $ fvRequired view:.optional>
-        $if withLabels
-                <label for=#{fvId view}>#{fvLabel view}
-        $maybe tt <- fvTooltip view
-            <div .tooltip>#{tt}
-        ^{fvInput view}
-        $maybe err <- fvErrors view
-            <div .errors>#{err}
-|]
+    let widget =     do { (asWidgetT . toWidget) (toHtml fragment);
+         Data.Foldable.mapM_
+           (\ view_aNsz
+              -> do { (asWidgetT . toWidget)
+                        ((Text.Blaze.Internal.preEscapedText . pack) "<div");
+                      Text.Hamlet.condH
+                        [(or [fvRequired view_aNsz, not (fvRequired view_aNsz)], 
+                          do { (asWidgetT . toWidget)
+                                 ((Text.Blaze.Internal.preEscapedText . pack) " class=\"");
+                               Text.Hamlet.condH
+                                 [(fvRequired view_aNsz, 
+                                   (asWidgetT . toWidget)
+                                     ((Text.Blaze.Internal.preEscapedText . pack) "required "))]
+                                 Nothing;
+                               Text.Hamlet.condH
+                                 [(not (fvRequired view_aNsz), 
+                                   (asWidgetT . toWidget)
+                                     ((Text.Blaze.Internal.preEscapedText . pack) "optional"))]
+                                 Nothing;
+                               (asWidgetT . toWidget)
+                                 ((Text.Blaze.Internal.preEscapedText . pack) "\"") })]
+                        Nothing;
+                      (asWidgetT . toWidget)
+                        ((Text.Blaze.Internal.preEscapedText . pack) ">");
+                      Text.Hamlet.condH
+                        [(withLabels, 
+                          do { (asWidgetT . toWidget)
+                                 ((Text.Blaze.Internal.preEscapedText . pack) "<label for=\"");
+                               (asWidgetT . toWidget) (toHtml (fvId view_aNsz));
+                               (asWidgetT . toWidget)
+                                 ((Text.Blaze.Internal.preEscapedText . pack) "\">");
+                               (asWidgetT . toWidget) (toHtml (fvLabel view_aNsz));
+                               (asWidgetT . toWidget)
+                                 ((Text.Blaze.Internal.preEscapedText . pack) "</label>") })]
+                        Nothing;
+                      Text.Hamlet.maybeH
+                        (fvTooltip view_aNsz)
+                        (\ tt_aNsL
+                           -> do { (asWidgetT . toWidget)
+                                     ((Text.Blaze.Internal.preEscapedText . pack)
+                                        "<div class=\"tooltip\">");
+                                   (asWidgetT . toWidget) (toHtml tt_aNsL);
+                                   (asWidgetT . toWidget)
+                                     ((Text.Blaze.Internal.preEscapedText . pack) "</div>") })
+                        Nothing;
+                      (asWidgetT . toWidget) (fvInput view_aNsz);
+                      Text.Hamlet.maybeH
+                        (fvErrors view_aNsz)
+                        (\ err_aNsP
+                           -> do { (asWidgetT . toWidget)
+                                     ((Text.Blaze.Internal.preEscapedText . pack)
+                                        "<div class=\"errors\">");
+                                   (asWidgetT . toWidget) (toHtml err_aNsP);
+                                   (asWidgetT . toWidget)
+                                     ((Text.Blaze.Internal.preEscapedText . pack) "</div>") })
+                        Nothing;
+                      (asWidgetT . toWidget)
+                        ((Text.Blaze.Internal.preEscapedText . pack) "</div>") })
+           views }
+
     return (res, widget)
 
 -- | Render a form using Bootstrap v2-friendly shamlet syntax.
@@ -437,19 +551,62 @@ renderBootstrap2 aform fragment = do
     let views = views' []
         has (Just _) = True
         has Nothing  = False
-    let widget = [whamlet|
-                $newline never
-                \#{fragment}
-                $forall view <- views
-                    <div .control-group .clearfix :fvRequired view:.required :not $ fvRequired view:.optional :has $ fvErrors view:.error>
-                        <label .control-label for=#{fvId view}>#{fvLabel view}
-                        <div .controls .input>
-                            ^{fvInput view}
-                            $maybe tt <- fvTooltip view
-                                <span .help-block>#{tt}
-                            $maybe err <- fvErrors view
-                                <span .help-block>#{err}
-                |]
+    let widget =     do { (asWidgetT . toWidget) (toHtml fragment);
+         Data.Foldable.mapM_
+           (\ view_aNw8
+              -> do { (asWidgetT . toWidget)
+                        ((Text.Blaze.Internal.preEscapedText . pack)
+                           "<div class=\"control-group clearfix ");
+                      Text.Hamlet.condH
+                        [(fvRequired view_aNw8, 
+                          (asWidgetT . toWidget)
+                            ((Text.Blaze.Internal.preEscapedText . pack) "required "))]
+                        Nothing;
+                      Text.Hamlet.condH
+                        [(not (fvRequired view_aNw8), 
+                          (asWidgetT . toWidget)
+                            ((Text.Blaze.Internal.preEscapedText . pack) "optional "))]
+                        Nothing;
+                      Text.Hamlet.condH
+                        [(has (fvErrors view_aNw8), 
+                          (asWidgetT . toWidget)
+                            ((Text.Blaze.Internal.preEscapedText . pack) "error"))]
+                        Nothing;
+                      (asWidgetT . toWidget)
+                        ((Text.Blaze.Internal.preEscapedText . pack)
+                           "\"><label class=\"control-label\" for=\"");
+                      (asWidgetT . toWidget) (toHtml (fvId view_aNw8));
+                      (asWidgetT . toWidget)
+                        ((Text.Blaze.Internal.preEscapedText . pack) "\">");
+                      (asWidgetT . toWidget) (toHtml (fvLabel view_aNw8));
+                      (asWidgetT . toWidget)
+                        ((Text.Blaze.Internal.preEscapedText . pack)
+                           "</label><div class=\"controls input\">");
+                      (asWidgetT . toWidget) (fvInput view_aNw8);
+                      Text.Hamlet.maybeH
+                        (fvTooltip view_aNw8)
+                        (\ tt_aNw9
+                           -> do { (asWidgetT . toWidget)
+                                     ((Text.Blaze.Internal.preEscapedText . pack)
+                                        "<span class=\"help-block\">");
+                                   (asWidgetT . toWidget) (toHtml tt_aNw9);
+                                   (asWidgetT . toWidget)
+                                     ((Text.Blaze.Internal.preEscapedText . pack) "</span>") })
+                        Nothing;
+                      Text.Hamlet.maybeH
+                        (fvErrors view_aNw8)
+                        (\ err_aNwa
+                           -> do { (asWidgetT . toWidget)
+                                     ((Text.Blaze.Internal.preEscapedText . pack)
+                                        "<span class=\"help-block\">");
+                                   (asWidgetT . toWidget) (toHtml err_aNwa);
+                                   (asWidgetT . toWidget)
+                                     ((Text.Blaze.Internal.preEscapedText . pack) "</span>") })
+                        Nothing;
+                      (asWidgetT . toWidget)
+                        ((Text.Blaze.Internal.preEscapedText . pack) "</div></div>") })
+           views }
+
     return (res, widget)
 
 -- | Deprecated synonym for 'renderBootstrap2'.
diff --git a/Yesod/Form/Jquery.hs b/Yesod/Form/Jquery.hs
index 63e3d57..47503c2 100644
--- a/Yesod/Form/Jquery.hs
+++ b/Yesod/Form/Jquery.hs
@@ -18,11 +18,23 @@ import Yesod.Core
 import Yesod.Form
 import Data.Time (Day)
 import Data.Default
-import Text.Hamlet (shamlet)
-import Text.Julius (julius, rawJS)
+import Text.Julius (rawJS)
 import Data.Text (Text, pack, unpack)
 import Data.Monoid (mconcat)
 
+import qualified Text.Blaze as Text.Blaze.Internal
+import qualified Text.Blaze.Internal
+import qualified Text.Hamlet
+import qualified Yesod.Core.Widget
+import qualified Text.Css
+import qualified Data.Monoid
+import qualified Data.Foldable
+import qualified Control.Monad
+import qualified Text.Julius
+import qualified Data.Text.Lazy.Builder
+import qualified Text.Shakespeare
+import qualified Data.Text.Lazy.Builder as Data.Text.Internal.Builder
+
 -- | Gets the Google hosted jQuery UI 1.8 CSS file with the given theme.
 googleHostedJqueryUiCss :: Text -> Text
 googleHostedJqueryUiCss theme = mconcat
@@ -71,27 +83,54 @@ jqueryDayField' jds inputType = Field
               . readMay
               . unpack
     , fieldView = \theId name attrs val isReq -> do
-        toWidget [shamlet|
-$newline never
-<input id="#{theId}" name="#{name}" *{attrs} type="#{inputType}" :isReq:required="" value="#{showVal val}">
-|]
+        toWidget  $         do { id
+               ((Text.Blaze.Internal.preEscapedText . pack) "<input id=\"");
+             id (toHtml theId);
+             id ((Text.Blaze.Internal.preEscapedText . pack) "\" name=\"");
+             id (toHtml name);
+             id ((Text.Blaze.Internal.preEscapedText . pack) "\" type=\"");
+             id (toHtml inputType);
+             id ((Text.Blaze.Internal.preEscapedText . pack) "\"");
+             Text.Hamlet.condH
+               [(isReq, 
+                 id ((Text.Blaze.Internal.preEscapedText . pack) " required=\"\""))]
+               Nothing;
+             id ((Text.Blaze.Internal.preEscapedText . pack) " value=\"");
+             id (toHtml (showVal val));
+             id ((Text.Blaze.Internal.preEscapedText . pack) "\"");
+             id ((Text.Hamlet.attrsToHtml . Text.Hamlet.toAttributes) attrs);
+             id ((Text.Blaze.Internal.preEscapedText . pack) ">") }
+
         addScript' urlJqueryJs
         addScript' urlJqueryUiJs
         addStylesheet' urlJqueryUiCss
-        toWidget [julius|
-$(function(){
-    var i = document.getElementById("#{rawJS theId}");
-    if (i.type != "date") {
-        $(i).datepicker({
-            dateFormat:'yy-mm-dd',
-            changeMonth:#{jsBool $ jdsChangeMonth jds},
-            changeYear:#{jsBool $ jdsChangeYear jds},
-            numberOfMonths:#{rawJS $ mos $ jdsNumberOfMonths jds},
-            yearRange:#{toJSON $ jdsYearRange jds}
-        });
-    }
-});
-|]
+        toWidget  $         Text.Julius.asJavascriptUrl
+          (\ _render_a3iGM
+             -> mconcat
+                  [Text.Julius.Javascript
+                     ((Data.Text.Internal.Builder.fromText . Text.Shakespeare.pack')
+                        "\n\n$(function(){\n\n    var i = document.getElementById(\""),
+                   Text.Julius.toJavascript (rawJS theId),
+                   Text.Julius.Javascript
+                     ((Data.Text.Internal.Builder.fromText . Text.Shakespeare.pack')
+                        "\");\n\n    if (i.type != \"date\") {\n\n        $(i).datepicker({\n\n            dateFormat:'yy-mm-dd',\n\n            changeMonth:"),
+                   Text.Julius.toJavascript (jsBool (jdsChangeMonth jds)),
+                   Text.Julius.Javascript
+                     ((Data.Text.Internal.Builder.fromText . Text.Shakespeare.pack')
+                        ",\n\n            changeYear:"),
+                   Text.Julius.toJavascript (jsBool (jdsChangeYear jds)),
+                   Text.Julius.Javascript
+                     ((Data.Text.Internal.Builder.fromText . Text.Shakespeare.pack')
+                        ",\n\n            numberOfMonths:"),
+                   Text.Julius.toJavascript (rawJS (mos (jdsNumberOfMonths jds))),
+                   Text.Julius.Javascript
+                     ((Data.Text.Internal.Builder.fromText . Text.Shakespeare.pack')
+                        ",\n\n            yearRange:"),
+                   Text.Julius.toJavascript (toJSON (jdsYearRange jds)),
+                   Text.Julius.Javascript
+                     ((Data.Text.Internal.Builder.fromText . Text.Shakespeare.pack')
+                        "\n\n        });\n\n    }\n\n});")])
+
     , fieldEnctype = UrlEncoded
     }
   where
@@ -118,16 +157,47 @@ jqueryAutocompleteField' :: (RenderMessage site FormMessage, YesodJquery site)
 jqueryAutocompleteField' minLen src = Field
     { fieldParse = parseHelper $ Right
     , fieldView = \theId name attrs val isReq -> do
-        toWidget [shamlet|
-$newline never
-<input id="#{theId}" name="#{name}" *{attrs} type="text" :isReq:required="" value="#{either id id val}" .autocomplete>
-|]
+        toWidget  $         do { id
+               ((Text.Blaze.Internal.preEscapedText . pack)
+                  "<input class=\"autocomplete\" id=\"");
+             id (toHtml theId);
+             id ((Text.Blaze.Internal.preEscapedText . pack) "\" name=\"");
+             id (toHtml name);
+             id
+               ((Text.Blaze.Internal.preEscapedText . pack) "\" type=\"text\"");
+             Text.Hamlet.condH
+               [(isReq, 
+                 id ((Text.Blaze.Internal.preEscapedText . pack) " required=\"\""))]
+               Nothing;
+             id ((Text.Blaze.Internal.preEscapedText . pack) " value=\"");
+             id (toHtml (either id id val));
+             id ((Text.Blaze.Internal.preEscapedText . pack) "\"");
+             id ((Text.Hamlet.attrsToHtml . Text.Hamlet.toAttributes) attrs);
+             id ((Text.Blaze.Internal.preEscapedText . pack) ">") }
+
         addScript' urlJqueryJs
         addScript' urlJqueryUiJs
         addStylesheet' urlJqueryUiCss
-        toWidget [julius|
-$(function(){$("##{rawJS theId}").autocomplete({source:"@{src}",minLength:#{toJSON minLen}})});
-|]
+        toWidget  $         Text.Julius.asJavascriptUrl
+          (\ _render_a3iHO
+             -> mconcat
+                  [Text.Julius.Javascript
+                     ((Data.Text.Internal.Builder.fromText . Text.Shakespeare.pack')
+                        "\n\n$(function(){$(\"#"),
+                   Text.Julius.toJavascript (rawJS theId),
+                   Text.Julius.Javascript
+                     ((Data.Text.Internal.Builder.fromText . Text.Shakespeare.pack')
+                        "\").autocomplete({source:\""),
+                   Text.Julius.Javascript
+                     (Data.Text.Internal.Builder.fromText (_render_a3iHO src [])),
+                   Text.Julius.Javascript
+                     ((Data.Text.Internal.Builder.fromText . Text.Shakespeare.pack')
+                        "\",minLength:"),
+                   Text.Julius.toJavascript (toJSON minLen),
+                   Text.Julius.Javascript
+                     ((Data.Text.Internal.Builder.fromText . Text.Shakespeare.pack')
+                        "})});")])
+
     , fieldEnctype = UrlEncoded
     }
 
diff --git a/Yesod/Form/MassInput.hs b/Yesod/Form/MassInput.hs
index a2b434d..29b45b5 100644
--- a/Yesod/Form/MassInput.hs
+++ b/Yesod/Form/MassInput.hs
@@ -22,6 +22,16 @@ import Data.Traversable (sequenceA)
 import qualified Data.Map as Map
 import Data.Maybe (listToMaybe)
 
+import qualified Data.Text
+import qualified Text.Blaze as Text.Blaze.Internal
+import qualified Text.Blaze.Internal
+import qualified Text.Hamlet
+import qualified Yesod.Core.Widget
+import qualified Text.Css
+import qualified Data.Monoid
+import qualified Data.Foldable
+import qualified Control.Monad
+
 down :: Monad m => Int -> MForm m ()
 down 0 = return ()
 down i | i < 0 = error "called down with a negative number"
@@ -70,16 +80,27 @@ inputList label fixXml single mdef = formToAForm $ do
         { fvLabel = label
         , fvTooltip = Nothing
         , fvId = theId
-        , fvInput = [whamlet|
-$newline never
-^{fixXml views}
-<p>
-    $forall xml <- xmls
-        ^{xml}
-    <input .count type=hidden name=#{countName} value=#{count}>
-    <input type=checkbox name=#{addName}>
-    Add another row
-|]
+        , fvInput =         do { (asWidgetT . toWidget) (fixXml views);
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . Data.Text.pack) "<p>");
+             Data.Foldable.mapM_
+               (\ xml_a3hPg -> (asWidgetT . toWidget) xml_a3hPg) xmls;
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                  "<input class=\"count\" type=\"hidden\" name=\"");
+             (asWidgetT . toWidget) (toHtml countName);
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                  "\" value=\"");
+             (asWidgetT . toWidget) (toHtml count);
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                  "\"><input type=\"checkbox\" name=\"");
+             (asWidgetT . toWidget) (toHtml addName);
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                  "\">Add another row</p>") }
+
         , fvErrors = Nothing
         , fvRequired = False
         }])
@@ -92,10 +113,14 @@ withDelete af = do
     deleteName <- newFormIdent
     (menv, _, _) <- ask
     res <- case menv >>= Map.lookup deleteName . fst of
-        Just ("yes":_) -> return $ Left [whamlet|
-$newline never
-<input type=hidden name=#{deleteName} value=yes>
-|]
+        Just ("yes":_) -> return $ Left  $         do { (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                  "<input type=\"hidden\" name=\"");
+             (asWidgetT . toWidget) (toHtml deleteName);
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                  "\" value=\"yes\">") }
+
         _ -> do
             (_, xml2) <- aFormToForm $ areq checkBoxField FieldSettings
                 { fsLabel = SomeMessage MsgDelete
@@ -121,32 +146,149 @@ fixme eithers =
 massDivs, massTable
          :: [[FieldView site]]
          -> WidgetT site IO ()
-massDivs viewss = [whamlet|
-$newline never
-$forall views <- viewss
-    <fieldset>
-        $forall view <- views
-            <div :fvRequired view:.required :not $ fvRequired view:.optional>
-                <label for=#{fvId view}>#{fvLabel view}
-                $maybe tt <- fvTooltip view
-                    <div .tooltip>#{tt}
-                ^{fvInput view}
-                $maybe err <- fvErrors view
-                    <div .errors>#{err}
-|]
+massDivs viewss = Data.Foldable.mapM_
+  (\ views_a3hPz
+     -> do { (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                  "<fieldset>");
+             Data.Foldable.mapM_
+               (\ view_a3hPA
+                  -> do { (asWidgetT . toWidget)
+                            ((Text.Blaze.Internal.preEscapedText . Data.Text.pack) "<div");
+                          Text.Hamlet.condH
+                            [(or [fvRequired view_a3hPA, not (fvRequired view_a3hPA)], 
+                              do { (asWidgetT . toWidget)
+                                     ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                                        " class=\"");
+                                   Text.Hamlet.condH
+                                     [(fvRequired view_a3hPA, 
+                                       (asWidgetT . toWidget)
+                                         ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                                            "required "))]
+                                     Nothing;
+                                   Text.Hamlet.condH
+                                     [(not (fvRequired view_a3hPA), 
+                                       (asWidgetT . toWidget)
+                                         ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                                            "optional"))]
+                                     Nothing;
+                                   (asWidgetT . toWidget)
+                                     ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                                        "\"") })]
+                            Nothing;
+                          (asWidgetT . toWidget)
+                            ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                               "><label for=\"");
+                          (asWidgetT . toWidget) (toHtml (fvId view_a3hPA));
+                          (asWidgetT . toWidget)
+                            ((Text.Blaze.Internal.preEscapedText . Data.Text.pack) "\">");
+                          (asWidgetT . toWidget) (toHtml (fvLabel view_a3hPA));
+                          (asWidgetT . toWidget)
+                            ((Text.Blaze.Internal.preEscapedText . Data.Text.pack) "</label>");
+                          Text.Hamlet.maybeH
+                            (fvTooltip view_a3hPA)
+                            (\ tt_a3hPB
+                               -> do { (asWidgetT . toWidget)
+                                         ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                                            "<div class=\"tooltip\">");
+                                       (asWidgetT . toWidget) (toHtml tt_a3hPB);
+                                       (asWidgetT . toWidget)
+                                         ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                                            "</div>") })
+                            Nothing;
+                          (asWidgetT . toWidget) (fvInput view_a3hPA);
+                          Text.Hamlet.maybeH
+                            (fvErrors view_a3hPA)
+                            (\ err_a3hPC
+                               -> do { (asWidgetT . toWidget)
+                                         ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                                            "<div class=\"errors\">");
+                                       (asWidgetT . toWidget) (toHtml err_a3hPC);
+                                       (asWidgetT . toWidget)
+                                         ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                                            "</div>") })
+                            Nothing;
+                          (asWidgetT . toWidget)
+                            ((Text.Blaze.Internal.preEscapedText . Data.Text.pack) "</div>") })
+               views_a3hPz;
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                  "</fieldset>") })
+  viewss
+
+
+massTable viewss = Data.Foldable.mapM_
+  (\ views_a3hPH
+     -> do { (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                  "<fieldset><table>");
+             Data.Foldable.mapM_
+               (\ view_a3hPI
+                  -> do { (asWidgetT . toWidget)
+                            ((Text.Blaze.Internal.preEscapedText . Data.Text.pack) "<tr");
+                          Text.Hamlet.condH
+                            [(or [fvRequired view_a3hPI, not (fvRequired view_a3hPI)], 
+                              do { (asWidgetT . toWidget)
+                                     ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                                        " class=\"");
+                                   Text.Hamlet.condH
+                                     [(fvRequired view_a3hPI, 
+                                       (asWidgetT . toWidget)
+                                         ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                                            "required "))]
+                                     Nothing;
+                                   Text.Hamlet.condH
+                                     [(not (fvRequired view_a3hPI), 
+                                       (asWidgetT . toWidget)
+                                         ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                                            "optional"))]
+                                     Nothing;
+                                   (asWidgetT . toWidget)
+                                     ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                                        "\"") })]
+                            Nothing;
+                          (asWidgetT . toWidget)
+                            ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                               "><td><label for=\"");
+                          (asWidgetT . toWidget) (toHtml (fvId view_a3hPI));
+                          (asWidgetT . toWidget)
+                            ((Text.Blaze.Internal.preEscapedText . Data.Text.pack) "\">");
+                          (asWidgetT . toWidget) (toHtml (fvLabel view_a3hPI));
+                          (asWidgetT . toWidget)
+                            ((Text.Blaze.Internal.preEscapedText . Data.Text.pack) "</label>");
+                          Text.Hamlet.maybeH
+                            (fvTooltip view_a3hPI)
+                            (\ tt_a3hPJ
+                               -> do { (asWidgetT . toWidget)
+                                         ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                                            "<div class=\"tooltip\">");
+                                       (asWidgetT . toWidget) (toHtml tt_a3hPJ);
+                                       (asWidgetT . toWidget)
+                                         ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                                            "</div>") })
+                            Nothing;
+                          (asWidgetT . toWidget)
+                            ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                               "</td><td>");
+                          (asWidgetT . toWidget) (fvInput view_a3hPI);
+                          (asWidgetT . toWidget)
+                            ((Text.Blaze.Internal.preEscapedText . Data.Text.pack) "</td>");
+                          Text.Hamlet.maybeH
+                            (fvErrors view_a3hPI)
+                            (\ err_a3hPK
+                               -> do { (asWidgetT . toWidget)
+                                         ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                                            "<td class=\"errors\">");
+                                       (asWidgetT . toWidget) (toHtml err_a3hPK);
+                                       (asWidgetT . toWidget)
+                                         ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                                            "</td>") })
+                            Nothing;
+                          (asWidgetT . toWidget)
+                            ((Text.Blaze.Internal.preEscapedText . Data.Text.pack) "</tr>") })
+               views_a3hPH;
+             (asWidgetT . toWidget)
+               ((Text.Blaze.Internal.preEscapedText . Data.Text.pack)
+                  "</table></fieldset>") })
+  viewss
 
-massTable viewss = [whamlet|
-$newline never
-$forall views <- viewss
-    <fieldset>
-        <table>
-            $forall view <- views
-                <tr :fvRequired view:.required :not $ fvRequired view:.optional>
-                    <td>
-                        <label for=#{fvId view}>#{fvLabel view}
-                        $maybe tt <- fvTooltip view
-                            <div .tooltip>#{tt}
-                    <td>^{fvInput view}
-                    $maybe err <- fvErrors view
-                        <td .errors>#{err}
-|]
diff --git a/Yesod/Form/Nic.hs b/Yesod/Form/Nic.hs
index 2862678..a773553 100644
--- a/Yesod/Form/Nic.hs
+++ b/Yesod/Form/Nic.hs
@@ -12,12 +12,24 @@ module Yesod.Form.Nic
 import Yesod.Core
 import Yesod.Form
 import Text.HTML.SanitizeXSS (sanitizeBalance)
-import Text.Hamlet (shamlet)
-import Text.Julius (julius, rawJS)
+import Text.Julius (rawJS)
 import Text.Blaze.Html.Renderer.String (renderHtml)
 import Data.Text (Text, pack)
 import Data.Maybe (listToMaybe)
 
+import qualified Text.Blaze as Text.Blaze.Internal
+import qualified Text.Blaze.Internal
+import qualified Text.Hamlet
+import qualified Yesod.Core.Widget
+import qualified Text.Css
+import qualified Data.Monoid
+import qualified Data.Foldable
+import qualified Control.Monad
+import qualified Text.Julius
+import qualified Data.Text.Lazy.Builder
+import qualified Data.Text.Lazy.Builder as Data.Text.Internal.Builder
+import qualified Text.Shakespeare
+
 class Yesod a => YesodNic a where
     -- | NIC Editor Javascript file.
     urlNicEdit :: a -> Either (Route a) Text
@@ -27,20 +39,44 @@ nicHtmlField :: YesodNic site => Field (HandlerT site IO) Html
 nicHtmlField = Field
     { fieldParse = \e _ -> return . Right . fmap (preEscapedToMarkup . sanitizeBalance) . listToMaybe $ e
     , fieldView = \theId name attrs val _isReq -> do
-        toWidget [shamlet|
-$newline never
-    <textarea id="#{theId}" *{attrs} name="#{name}" .html>#{showVal val}
-|]
+        toWidget  $         do { id
+               ((Text.Blaze.Internal.preEscapedText . pack)
+                  "<textarea class=\"html\" id=\"");
+             id (toHtml theId);
+             id ((Text.Blaze.Internal.preEscapedText . pack) "\" name=\"");
+             id (toHtml name);
+             id ((Text.Blaze.Internal.preEscapedText . pack) "\"");
+             id ((Text.Hamlet.attrsToHtml . Text.Hamlet.toAttributes) attrs);
+             id ((Text.Blaze.Internal.preEscapedText . pack) ">");
+             id (toHtml (showVal val));
+             id ((Text.Blaze.Internal.preEscapedText . pack) "</textarea>") }
+
         addScript' urlNicEdit
         master <- getYesod
         toWidget $
           case jsLoader master of
-            BottomOfHeadBlocking -> [julius|
-bkLib.onDomLoaded(function(){new nicEditor({fullPanel:true}).panelInstance("#{rawJS theId}")});
-|]
-            _ -> [julius|
-(function(){new nicEditor({fullPanel:true}).panelInstance("#{rawJS theId}")})();
-|]
+            BottomOfHeadBlocking ->             Text.Julius.asJavascriptUrl
+              (\ _render_a3hYy
+                 -> Data.Monoid.mconcat
+                      [Text.Julius.Javascript
+                         ((Data.Text.Internal.Builder.fromText . Text.Shakespeare.pack')
+                            "\n\nbkLib.onDomLoaded(function(){new nicEditor({fullPanel:true}).panelInstance(\""),
+                       Text.Julius.toJavascript (rawJS theId),
+                       Text.Julius.Javascript
+                         ((Data.Text.Internal.Builder.fromText . Text.Shakespeare.pack')
+                            "\")});")])
+
+            _ ->             Text.Julius.asJavascriptUrl
+              (\ _render_a3i1Q
+                 -> Data.Monoid.mconcat
+                      [Text.Julius.Javascript
+                         ((Data.Text.Internal.Builder.fromText . Text.Shakespeare.pack')
+                            "\n\n(function(){new nicEditor({fullPanel:true}).panelInstance(\""),
+                       Text.Julius.toJavascript (rawJS theId),
+                       Text.Julius.Javascript
+                         ((Data.Text.Internal.Builder.fromText . Text.Shakespeare.pack')
+                            "\")})();")])
+
     , fieldEnctype = UrlEncoded
     }
   where
diff --git a/yesod-form.cabal b/yesod-form.cabal
index 7849763..9694fe1 100644
--- a/yesod-form.cabal
+++ b/yesod-form.cabal
@@ -23,7 +23,7 @@ library
                    , yesod-core            >= 1.4      && < 1.5
                    , yesod-persistent      >= 1.4      && < 1.5
                    , time                  >= 1.1.4
-                   , shakespeare           >= 2.0
+                   , shakespeare           >= 2.0.5
                    , persistent
                    , template-haskell
                    , transformers          >= 0.2.2
-- 
2.1.4