frontsau 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (280) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE +21 -0
  5. data/README.md +30 -0
  6. data/Rakefile +2 -0
  7. data/bin/frontsau +15 -0
  8. data/bin/frontsau-phaml-compiler +35 -0
  9. data/example/.frontsau +12 -0
  10. data/example/assets/head.jpg +0 -0
  11. data/example/assets/script.js +4 -0
  12. data/example/assets/style.css +6 -0
  13. data/example/css/includes.sass +2 -0
  14. data/example/css/style.sass +6 -0
  15. data/example/image/head.jpg +0 -0
  16. data/example/index.html +0 -0
  17. data/example/js/script.coffee +1 -0
  18. data/frontsau.gemspec +41 -0
  19. data/lib/Phamlp/Phamlp.php +72 -0
  20. data/lib/Phamlp/PhamlpException.php +31 -0
  21. data/lib/Phamlp/haml/HamlException.php +29 -0
  22. data/lib/Phamlp/haml/HamlHelpers.php +199 -0
  23. data/lib/Phamlp/haml/HamlParser.php +1250 -0
  24. data/lib/Phamlp/haml/filters/HamlBaseFilter.php +30 -0
  25. data/lib/Phamlp/haml/filters/HamlCdataFilter.php +29 -0
  26. data/lib/Phamlp/haml/filters/HamlCssFilter.php +30 -0
  27. data/lib/Phamlp/haml/filters/HamlEscapedFilter.php +32 -0
  28. data/lib/Phamlp/haml/filters/HamlJavascriptFilter.php +31 -0
  29. data/lib/Phamlp/haml/filters/HamlPhpFilter.php +27 -0
  30. data/lib/Phamlp/haml/filters/HamlPlainFilter.php +28 -0
  31. data/lib/Phamlp/haml/filters/HamlPreserveFilter.php +29 -0
  32. data/lib/Phamlp/haml/filters/HamlSassFilter.php +37 -0
  33. data/lib/Phamlp/haml/filters/HamlScssFilter.php +37 -0
  34. data/lib/Phamlp/haml/filters/_HamlMarkdownFilter.php +50 -0
  35. data/lib/Phamlp/haml/filters/_HamlTextileFilter.php +50 -0
  36. data/lib/Phamlp/haml/messages/_i18n.php +32 -0
  37. data/lib/Phamlp/haml/messages/de.php +32 -0
  38. data/lib/Phamlp/haml/messages/fr.php +32 -0
  39. data/lib/Phamlp/haml/renderers/HamlCompactRenderer.php +32 -0
  40. data/lib/Phamlp/haml/renderers/HamlCompressedRenderer.php +48 -0
  41. data/lib/Phamlp/haml/renderers/HamlExpandedRenderer.php +58 -0
  42. data/lib/Phamlp/haml/renderers/HamlNestedRenderer.php +77 -0
  43. data/lib/Phamlp/haml/renderers/HamlRenderer.php +137 -0
  44. data/lib/Phamlp/haml/tree/HamlCodeBlockNode.php +58 -0
  45. data/lib/Phamlp/haml/tree/HamlCommentNode.php +41 -0
  46. data/lib/Phamlp/haml/tree/HamlDoctypeNode.php +27 -0
  47. data/lib/Phamlp/haml/tree/HamlElementNode.php +52 -0
  48. data/lib/Phamlp/haml/tree/HamlFilterNode.php +50 -0
  49. data/lib/Phamlp/haml/tree/HamlHelperNode.php +73 -0
  50. data/lib/Phamlp/haml/tree/HamlNode.php +253 -0
  51. data/lib/Phamlp/haml/tree/HamlNodeExceptions.php +19 -0
  52. data/lib/Phamlp/haml/tree/HamlRootNode.php +58 -0
  53. data/lib/Phamlp/sass/SassException.php +29 -0
  54. data/lib/Phamlp/sass/SassFile.php +164 -0
  55. data/lib/Phamlp/sass/SassParser.php +848 -0
  56. data/lib/Phamlp/sass/extensions/compass/config.php +65 -0
  57. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/_blueprint.scss +47 -0
  58. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_buttons.scss +101 -0
  59. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_colors.scss +32 -0
  60. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_debug.scss +11 -0
  61. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_fancy-type.scss +86 -0
  62. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_form.scss +68 -0
  63. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_grid.scss +249 -0
  64. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_ie.scss +109 -0
  65. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_interaction.scss +57 -0
  66. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_link-icons.scss +37 -0
  67. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_liquid.scss +147 -0
  68. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_print.scss +93 -0
  69. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_reset.scss +3 -0
  70. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_rtl.scss +133 -0
  71. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_scaffolding.scss +54 -0
  72. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_typography.scss +104 -0
  73. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_utilities.scss +37 -0
  74. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/reset/_utilities.scss +58 -0
  75. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/basic/grid.png +0 -0
  76. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/basic/ie.sass +4 -0
  77. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/basic/manifest.rb +30 -0
  78. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/basic/partials/_base.sass +10 -0
  79. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/basic/print.sass +4 -0
  80. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/basic/screen.sass +12 -0
  81. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/buttons/buttons/cross.png +0 -0
  82. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/buttons/buttons/key.png +0 -0
  83. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/buttons/buttons/tick.png +0 -0
  84. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/buttons/buttons.sass +49 -0
  85. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/buttons/manifest.rb +17 -0
  86. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/link_icons/link_icons/doc.png +0 -0
  87. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/link_icons/link_icons/email.png +0 -0
  88. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/link_icons/link_icons/external.png +0 -0
  89. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/link_icons/link_icons/feed.png +0 -0
  90. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/link_icons/link_icons/im.png +0 -0
  91. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/link_icons/link_icons/pdf.png +0 -0
  92. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/link_icons/link_icons/visited.png +0 -0
  93. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/link_icons/link_icons/xls.png +0 -0
  94. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/link_icons/link_icons.sass +13 -0
  95. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/link_icons/manifest.rb +23 -0
  96. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/project/grid.png +0 -0
  97. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/project/ie.sass +16 -0
  98. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/project/manifest.rb +30 -0
  99. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/project/partials/_base.sass +11 -0
  100. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/project/print.sass +8 -0
  101. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/project/screen.sass +45 -0
  102. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/semantic/grid.png +0 -0
  103. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/semantic/ie.sass +16 -0
  104. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/semantic/manifest.rb +33 -0
  105. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/semantic/partials/_base.sass +10 -0
  106. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/semantic/partials/_form.sass +6 -0
  107. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/semantic/partials/_page.sass +18 -0
  108. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/semantic/partials/_two_col.sass +38 -0
  109. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/semantic/print.sass +5 -0
  110. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/semantic/screen.sass +14 -0
  111. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/_compass.scss +2 -0
  112. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/_css3.scss +15 -0
  113. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/_layout.scss +1 -0
  114. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/_reset.scss +3 -0
  115. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/_utilities.scss +6 -0
  116. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_background-clip.scss +43 -0
  117. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_background-origin.scss +42 -0
  118. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_background-size.scss +14 -0
  119. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_border-radius.scss +135 -0
  120. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_box-shadow.scss +50 -0
  121. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_box-sizing.scss +13 -0
  122. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_box.scss +112 -0
  123. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_columns.scss +55 -0
  124. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_font-face.scss +33 -0
  125. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_gradient.scss +82 -0
  126. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_inline-block.scss +12 -0
  127. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_opacity.scss +27 -0
  128. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_shared.scss +47 -0
  129. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_text-shadow.scss +25 -0
  130. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_transform.scss +85 -0
  131. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_transition.scss +85 -0
  132. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/layout/_sticky-footer.scss +23 -0
  133. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/reset/_utilities.scss +133 -0
  134. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/_general.scss +6 -0
  135. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/_links.scss +3 -0
  136. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/_lists.scss +4 -0
  137. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/_print.scss +17 -0
  138. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/_sprites.scss +1 -0
  139. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/_tables.scss +3 -0
  140. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/_text.scss +3 -0
  141. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/general/_clearfix.scss +31 -0
  142. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/general/_float.scss +15 -0
  143. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/general/_hacks.scss +35 -0
  144. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/general/_min.scss +16 -0
  145. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/general/_reset.scss +2 -0
  146. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/general/_tabs.scss +1 -0
  147. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/general/_tag-cloud.scss +18 -0
  148. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/links/_hover-link.scss +5 -0
  149. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/links/_link-colors.scss +28 -0
  150. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/links/_unstyled-link.scss +7 -0
  151. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/lists/_bullets.scss +34 -0
  152. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/lists/_horizontal-list.scss +52 -0
  153. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/lists/_inline-block-list.scss +47 -0
  154. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/lists/_inline-list.scss +29 -0
  155. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/sprites/_sprite-img.scss +56 -0
  156. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/tables/_alternating-rows-and-columns.scss +20 -0
  157. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/tables/_borders.scss +27 -0
  158. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/tables/_scaffolding.scss +9 -0
  159. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/text/_ellipsis.scss +25 -0
  160. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/text/_nowrap.scss +2 -0
  161. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/text/_replacement.scss +34 -0
  162. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/templates/ellipsis/ellipsis.sass +9 -0
  163. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/templates/ellipsis/manifest.rb +27 -0
  164. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/templates/ellipsis/xml/ellipsis.xml +14 -0
  165. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/templates/extension/manifest.rb +20 -0
  166. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/templates/extension/stylesheets/main.sass +1 -0
  167. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/templates/extension/templates/project/manifest.rb +2 -0
  168. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/templates/extension/templates/project/screen.sass +2 -0
  169. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/templates/project/USAGE.markdown +32 -0
  170. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/templates/project/ie.sass +6 -0
  171. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/templates/project/manifest.rb +4 -0
  172. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/templates/project/print.sass +6 -0
  173. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/templates/project/screen.sass +7 -0
  174. data/lib/Phamlp/sass/extensions/compass/functions/colourStops.php +268 -0
  175. data/lib/Phamlp/sass/extensions/compass/functions/constants.php +44 -0
  176. data/lib/Phamlp/sass/extensions/compass/functions/fontFiles.php +30 -0
  177. data/lib/Phamlp/sass/extensions/compass/functions/imageSize.php +39 -0
  178. data/lib/Phamlp/sass/extensions/compass/functions/inlineData.php +84 -0
  179. data/lib/Phamlp/sass/extensions/compass/functions/lists.php +47 -0
  180. data/lib/Phamlp/sass/extensions/compass/functions/selectors.php +128 -0
  181. data/lib/Phamlp/sass/extensions/compass/functions/urls.php +143 -0
  182. data/lib/Phamlp/sass/extensions/compass/stylesheets/_compass.scss +2 -0
  183. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/_css3.scss +15 -0
  184. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/_layout.scss +1 -0
  185. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/_reset.scss +3 -0
  186. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/_utilities.scss +6 -0
  187. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_background-clip.scss +43 -0
  188. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_background-origin.scss +42 -0
  189. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_background-size.scss +14 -0
  190. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_border-radius.scss +135 -0
  191. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_box-shadow.scss +50 -0
  192. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_box-sizing.scss +13 -0
  193. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_box.scss +112 -0
  194. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_columns.scss +55 -0
  195. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_font-face.scss +33 -0
  196. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_gradient.scss +96 -0
  197. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_inline-block.scss +12 -0
  198. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_opacity.scss +27 -0
  199. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_shared.scss +47 -0
  200. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_text-shadow.scss +25 -0
  201. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_transform.scss +85 -0
  202. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_transition.scss +85 -0
  203. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/layout/_sticky-footer.scss +23 -0
  204. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/reset/_utilities.scss +133 -0
  205. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/_general.scss +6 -0
  206. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/_links.scss +3 -0
  207. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/_lists.scss +4 -0
  208. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/_print.scss +17 -0
  209. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/_sprites.scss +1 -0
  210. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/_tables.scss +3 -0
  211. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/_text.scss +3 -0
  212. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/general/_clearfix.scss +31 -0
  213. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/general/_float.scss +15 -0
  214. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/general/_hacks.scss +35 -0
  215. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/general/_min.scss +16 -0
  216. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/general/_reset.scss +2 -0
  217. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/general/_tabs.scss +1 -0
  218. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/general/_tag-cloud.scss +18 -0
  219. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/links/_hover-link.scss +5 -0
  220. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/links/_link-colors.scss +28 -0
  221. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/links/_unstyled-link.scss +7 -0
  222. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/lists/_bullets.scss +34 -0
  223. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/lists/_horizontal-list.scss +52 -0
  224. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/lists/_inline-block-list.scss +47 -0
  225. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/lists/_inline-list.scss +29 -0
  226. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/sprites/_sprite-img.scss +56 -0
  227. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/tables/_alternating-rows-and-columns.scss +20 -0
  228. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/tables/_borders.scss +27 -0
  229. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/tables/_scaffolding.scss +9 -0
  230. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/text/_ellipsis.scss +25 -0
  231. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/text/_nowrap.scss +2 -0
  232. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/text/_replacement.scss +34 -0
  233. data/lib/Phamlp/sass/messages/_i18n.php +122 -0
  234. data/lib/Phamlp/sass/messages/de.php +70 -0
  235. data/lib/Phamlp/sass/messages/fr.php +70 -0
  236. data/lib/Phamlp/sass/renderers/SassCompactRenderer.php +130 -0
  237. data/lib/Phamlp/sass/renderers/SassCompressedRenderer.php +102 -0
  238. data/lib/Phamlp/sass/renderers/SassExpandedRenderer.php +62 -0
  239. data/lib/Phamlp/sass/renderers/SassNestedRenderer.php +61 -0
  240. data/lib/Phamlp/sass/renderers/SassRenderer.php +51 -0
  241. data/lib/Phamlp/sass/script/SassScriptFunction.php +169 -0
  242. data/lib/Phamlp/sass/script/SassScriptFunctions.php +751 -0
  243. data/lib/Phamlp/sass/script/SassScriptLexer.php +114 -0
  244. data/lib/Phamlp/sass/script/SassScriptOperation.php +151 -0
  245. data/lib/Phamlp/sass/script/SassScriptParser.php +192 -0
  246. data/lib/Phamlp/sass/script/SassScriptParserExceptions.php +40 -0
  247. data/lib/Phamlp/sass/script/SassScriptVariable.php +57 -0
  248. data/lib/Phamlp/sass/script/literals/SassBoolean.php +67 -0
  249. data/lib/Phamlp/sass/script/literals/SassColour.php +886 -0
  250. data/lib/Phamlp/sass/script/literals/SassLiteral.php +359 -0
  251. data/lib/Phamlp/sass/script/literals/SassLiteralExceptions.php +47 -0
  252. data/lib/Phamlp/sass/script/literals/SassNumber.php +503 -0
  253. data/lib/Phamlp/sass/script/literals/SassString.php +106 -0
  254. data/lib/Phamlp/sass/tree/SassCommentNode.php +64 -0
  255. data/lib/Phamlp/sass/tree/SassContext.php +120 -0
  256. data/lib/Phamlp/sass/tree/SassDebugNode.php +84 -0
  257. data/lib/Phamlp/sass/tree/SassDirectiveNode.php +76 -0
  258. data/lib/Phamlp/sass/tree/SassElseNode.php +28 -0
  259. data/lib/Phamlp/sass/tree/SassExtendNode.php +47 -0
  260. data/lib/Phamlp/sass/tree/SassForNode.php +99 -0
  261. data/lib/Phamlp/sass/tree/SassIfNode.php +95 -0
  262. data/lib/Phamlp/sass/tree/SassImportNode.php +69 -0
  263. data/lib/Phamlp/sass/tree/SassMixinDefinitionNode.php +88 -0
  264. data/lib/Phamlp/sass/tree/SassMixinNode.php +91 -0
  265. data/lib/Phamlp/sass/tree/SassNode.php +342 -0
  266. data/lib/Phamlp/sass/tree/SassNodeExceptions.php +117 -0
  267. data/lib/Phamlp/sass/tree/SassPropertyNode.php +239 -0
  268. data/lib/Phamlp/sass/tree/SassRootNode.php +100 -0
  269. data/lib/Phamlp/sass/tree/SassRuleNode.php +337 -0
  270. data/lib/Phamlp/sass/tree/SassVariableNode.php +90 -0
  271. data/lib/Phamlp/sass/tree/SassWhileNode.php +64 -0
  272. data/lib/frontsau/assets/rack.rb +12 -0
  273. data/lib/frontsau/assets/sprockets.rb +59 -0
  274. data/lib/frontsau/assets/static_assets_compiler.rb +50 -0
  275. data/lib/frontsau/assets/url_rewriter.rb +22 -0
  276. data/lib/frontsau/assets/watcher.rb +60 -0
  277. data/lib/frontsau/thor_app.rb +118 -0
  278. data/lib/frontsau/version.rb +3 -0
  279. data/lib/frontsau.rb +64 -0
  280. metadata +578 -0
@@ -0,0 +1,848 @@
1
+ <?php
2
+ /* SVN FILE: $Id: SassParser.php 118 2010-09-21 09:45:11Z chris.l.yates@gmail.com $ */
3
+ /**
4
+ * SassParser class file.
5
+ * See the {@link http://sass-lang.com/docs Sass documentation}
6
+ * for details of Sass.
7
+ *
8
+ * Credits:
9
+ * This is a port of Sass to PHP. All the genius comes from the people that
10
+ * invented and develop Sass; in particular:
11
+ * + {@link http://hamptoncatlin.com/ Hampton Catlin},
12
+ * + {@link http://nex-3.com/ Nathan Weizenbaum},
13
+ * + {@link http://chriseppstein.github.com/ Chris Eppstein}
14
+ *
15
+ * The bugs are mine. Please report any found at {@link http://code.google.com/p/phamlp/issues/list}
16
+ *
17
+ * @author Chris Yates <chris.l.yates@gmail.com>
18
+ * @copyright Copyright (c) 2010 PBM Web Development
19
+ * @license http://phamlp.googlecode.com/files/license.txt
20
+ * @package PHamlP
21
+ * @subpackage Sass
22
+ */
23
+
24
+ require_once('SassFile.php');
25
+ require_once('SassException.php');
26
+ require_once('tree/SassNode.php');
27
+
28
+ /**
29
+ * SassParser class.
30
+ * Parses {@link http://sass-lang.com/ .sass and .sccs} files.
31
+ * @package PHamlP
32
+ * @subpackage Sass
33
+ */
34
+ class SassParser {
35
+ /**#@+
36
+ * Default option values
37
+ */
38
+ const CACHE = true;
39
+ const CACHE_LOCATION = './sass-cache';
40
+ const CSS_LOCATION = './css';
41
+ const TEMPLATE_LOCATION = './sass-templates';
42
+ const BEGIN_COMMENT = '/';
43
+ const BEGIN_CSS_COMMENT = '/*';
44
+ const END_CSS_COMMENT = '*/';
45
+ const BEGIN_SASS_COMMENT= '//';
46
+ const BEGIN_INTERPOLATION = '#';
47
+ const BEGIN_INTERPOLATION_BLOCK = '#{';
48
+ const BEGIN_BLOCK = '{';
49
+ const END_BLOCK = '}';
50
+ const END_STATEMENT = ';';
51
+ const DOUBLE_QUOTE = '"';
52
+ const SINGLE_QUOTE = "'";
53
+
54
+ /**
55
+ * @var string the character used for indenting
56
+ * @see indentChars
57
+ * @see indentSpaces
58
+ */
59
+ private $indentChar;
60
+ /**
61
+ * @var array allowable characters for indenting
62
+ */
63
+ private $indentChars = array(' ', "\t");
64
+ /**
65
+ * @var integer number of spaces for indentation.
66
+ * Used to calculate {@link Level} if {@link indentChar} is space.
67
+ */
68
+ private $indentSpaces = 2;
69
+
70
+ /**
71
+ * @var string source
72
+ */
73
+ private $source;
74
+
75
+ /**#@+
76
+ * Option
77
+ */
78
+ /**
79
+ * cache:
80
+ * @var boolean Whether parsed Sass files should be cached, allowing greater
81
+ * speed.
82
+ *
83
+ * Defaults to true.
84
+ */
85
+ private $cache;
86
+
87
+ /**
88
+ * cache_location:
89
+ * @var string The path where the cached sassc files should be written to.
90
+ *
91
+ * Defaults to './sass-cache'.
92
+ */
93
+ private $cache_location;
94
+
95
+ /**
96
+ * css_location:
97
+ * @var string The path where CSS output should be written to.
98
+ *
99
+ * Defaults to './css'.
100
+ */
101
+ private $css_location;
102
+
103
+ /**
104
+ * debug_info:
105
+ * @var boolean When true the line number and file where a selector is defined
106
+ * is emitted into the compiled CSS in a format that can be understood by the
107
+ * {@link https://addons.mozilla.org/en-US/firefox/addon/103988/
108
+ * FireSass Firebug extension}.
109
+ * Disabled when using the compressed output style.
110
+ *
111
+ * Defaults to false.
112
+ * @see style
113
+ */
114
+ private $debug_info;
115
+
116
+ /**
117
+ * extensions:
118
+ * @var array Sass extensions, e.g. Compass. An associative array of the form
119
+ * $name => $options where $name is the name of the extension and $options
120
+ * is an array of name=>value options pairs.
121
+ */
122
+ protected $extensions;
123
+
124
+ /**
125
+ * filename:
126
+ * @var string The filename of the file being rendered.
127
+ * This is used solely for reporting errors.
128
+ */
129
+ protected $filename;
130
+
131
+ /**
132
+ * function_paths:
133
+ * @var array An array of filesystem paths which should be searched for
134
+ * SassScript functions.
135
+ */
136
+ private $function_paths;
137
+
138
+ /**
139
+ * line:
140
+ * @var integer The number of the first line of the Sass template. Used for
141
+ * reporting line numbers for errors. This is useful to set if the Sass
142
+ * template is embedded.
143
+ *
144
+ * Defaults to 1.
145
+ */
146
+ private $line;
147
+
148
+ /**
149
+ * line_numbers:
150
+ * @var boolean When true the line number and filename where a selector is
151
+ * defined is emitted into the compiled CSS as a comment. Useful for debugging
152
+ * especially when using imports and mixins.
153
+ * Disabled when using the compressed output style or the debug_info option.
154
+ *
155
+ * Defaults to false.
156
+ * @see debug_info
157
+ * @see style
158
+ */
159
+ private $line_numbers;
160
+
161
+ /**
162
+ * load_paths:
163
+ * @var array An array of filesystem paths which should be searched for
164
+ * Sass templates imported with the @import directive.
165
+ *
166
+ * Defaults to './sass-templates'.
167
+ */
168
+ private $load_paths;
169
+
170
+ /**
171
+ * property_syntax:
172
+ * @var string Forces the document to use one syntax for
173
+ * properties. If the correct syntax isn't used, an error is thrown.
174
+ * Value can be:
175
+ * + new - forces the use of a colon or equals sign after the property name.
176
+ * For example color: #0f3 or width: $main_width.
177
+ * + old - forces the use of a colon before the property name.
178
+ * For example: :color #0f3 or :width = $main_width.
179
+ *
180
+ * By default, either syntax is valid.
181
+ *
182
+ * Ignored for SCSS files which alaways use the new style.
183
+ */
184
+ private $property_syntax;
185
+
186
+ /**
187
+ * quiet:
188
+ * @var boolean When set to true, causes warnings to be disabled.
189
+ * Defaults to false.
190
+ */
191
+ private $quiet;
192
+
193
+ /**
194
+ * style:
195
+ * @var string the style of the CSS output.
196
+ * Value can be:
197
+ * + nested - Nested is the default Sass style, because it reflects the
198
+ * structure of the document in much the same way Sass does. Each selector
199
+ * and rule has its own line with indentation is based on how deeply the rule
200
+ * is nested. Nested style is very useful when looking at large CSS files as
201
+ * it allows you to very easily grasp the structure of the file without
202
+ * actually reading anything.
203
+ * + expanded - Expanded is the typical human-made CSS style, with each selector
204
+ * and property taking up one line. Selectors are not indented; properties are
205
+ * indented within the rules.
206
+ * + compact - Each CSS rule takes up only one line, with every property defined
207
+ * on that line. Nested rules are placed with each other while groups of rules
208
+ * are separated by a blank line.
209
+ * + compressed - Compressed has no whitespace except that necessary to separate
210
+ * selectors and properties. It's not meant to be human-readable.
211
+ *
212
+ * Defaults to 'nested'.
213
+ */
214
+ private $style;
215
+
216
+ /**
217
+ * syntax:
218
+ * @var string The syntax of the input file.
219
+ * 'sass' for the indented syntax and 'scss' for the CSS-extension syntax.
220
+ *
221
+ * This is set automatically when parsing a file, else defaults to 'sass'.
222
+ */
223
+ private $syntax;
224
+
225
+ /**
226
+ * template_location:
227
+ * @var string Path to the root sass template directory for your
228
+ * application.
229
+ */
230
+ private $template_location;
231
+
232
+ /**
233
+ * vendor_properties:
234
+ * If enabled a property need only be written in the standard form and vendor
235
+ * specific versions will be added to the style sheet.
236
+ * @var mixed array: vendor properties, merged with the built-in vendor
237
+ * properties, to automatically apply.
238
+ * Boolean true: use built in vendor properties.
239
+ *
240
+ * Defaults to vendor_properties disabled.
241
+ * @see _vendorProperties
242
+ */
243
+ private $vendor_properties = array();
244
+
245
+ /**#@-*/
246
+ /**
247
+ * Defines the build-in vendor properties
248
+ * @var array built-in vendor properties
249
+ * @see vendor_properties
250
+ */
251
+ private $_vendorProperties = array(
252
+ 'border-radius' => array(
253
+ '-moz-border-radius',
254
+ '-webkit-border-radius',
255
+ '-khtml-border-radius'
256
+ ),
257
+ 'border-top-right-radius' => array(
258
+ '-moz-border-radius-topright',
259
+ '-webkit-border-top-right-radius',
260
+ '-khtml-border-top-right-radius'
261
+ ),
262
+ 'border-bottom-right-radius' => array(
263
+ '-moz-border-radius-bottomright',
264
+ '-webkit-border-bottom-right-radius',
265
+ '-khtml-border-bottom-right-radius'
266
+ ),
267
+ 'border-bottom-left-radius' => array(
268
+ '-moz-border-radius-bottomleft',
269
+ '-webkit-border-bottom-left-radius',
270
+ '-khtml-border-bottom-left-radius'
271
+ ),
272
+ 'border-top-left-radius' => array(
273
+ '-moz-border-radius-topleft',
274
+ '-webkit-border-top-left-radius',
275
+ '-khtml-border-top-left-radius'
276
+ ),
277
+ 'box-shadow' => array('-moz-box-shadow', '-webkit-box-shadow'),
278
+ 'box-sizing' => array('-moz-box-sizing', '-webkit-box-sizing'),
279
+ 'opacity' => array('-moz-opacity', '-webkit-opacity', '-khtml-opacity'),
280
+ );
281
+
282
+ /**
283
+ * Constructor.
284
+ * Sets parser options
285
+ * @param array $options
286
+ * @return SassParser
287
+ */
288
+ public function __construct($options = array()) {
289
+ if (!is_array($options)) {
290
+ throw new SassException('{what} must be a {type}', array('{what}'=>'options', '{type}'=>'array'));
291
+ }
292
+ if (!empty($options['language'])) {
293
+ Phamlp::$language = $options['language'];
294
+ }
295
+
296
+ if (!empty($options['extensions'])) {
297
+ foreach ($options['extensions'] as $extension=>$extOptions) {
298
+ include dirname(__FILE__).DIRECTORY_SEPARATOR.'extensions'.DIRECTORY_SEPARATOR.$extension.DIRECTORY_SEPARATOR.'config.php';
299
+ $configClass = 'SassExtentions'.$extension.'Config';
300
+ $config = new $configClass;
301
+ $config->config($extOptions);
302
+
303
+ $lp = dirname(__FILE__).DIRECTORY_SEPARATOR.'extensions'.DIRECTORY_SEPARATOR.$extension.DIRECTORY_SEPARATOR.'frameworks';
304
+ $fp = dirname(__FILE__).DIRECTORY_SEPARATOR.'extensions'.DIRECTORY_SEPARATOR.$extension.DIRECTORY_SEPARATOR.'functions';
305
+ $options['load_paths'] = (empty($options['load_paths']) ?
306
+ array($lp) : array_merge($options['load_paths'], $lp));
307
+ $options['function_paths'] = (empty($options['function_paths']) ?
308
+ array($fp) : array_merge($options['function_paths'], $fp));
309
+ }
310
+ }
311
+
312
+ if (!empty($options['vendor_properties'])) {
313
+ if ($options['vendor_properties'] === true) {
314
+ $this->vendor_properties = $this->_vendorProperties;
315
+ }
316
+ elseif (is_array($options['vendor_properties'])) {
317
+ $this->vendor_properties = array_merge($this->vendor_properties, $this->_vendorProperties);
318
+ }
319
+ }
320
+ unset($options['language'], $options['vendor_properties']);
321
+
322
+ $defaultOptions = array(
323
+ 'cache' => self::CACHE,
324
+ 'cache_location' => dirname(__FILE__) . DIRECTORY_SEPARATOR . self::CACHE_LOCATION,
325
+ 'css_location' => dirname(__FILE__) . DIRECTORY_SEPARATOR . self::CSS_LOCATION,
326
+ 'debug_info' => false,
327
+ 'filename' => array('dirname' => '', 'basename' => ''),
328
+ 'function_paths' => array(),
329
+ 'load_paths' => array(dirname(__FILE__) . DIRECTORY_SEPARATOR . self::TEMPLATE_LOCATION),
330
+ 'line' => 1,
331
+ 'line_numbers' => false,
332
+ 'style' => SassRenderer::STYLE_NESTED,
333
+ 'syntax' => SassFile::SASS
334
+ );
335
+
336
+ foreach (array_merge($defaultOptions, $options) as $name=>$value) {
337
+ if (property_exists($this, $name)) {
338
+ $this->$name = $value;
339
+ }
340
+ }
341
+ }
342
+
343
+ /**
344
+ * Getter.
345
+ * @param string name of property to get
346
+ * @return mixed return value of getter function
347
+ */
348
+ public function __get($name) {
349
+ $getter = 'get' . ucfirst($name);
350
+ if (method_exists($this, $getter)) {
351
+ return $this->$getter();
352
+ }
353
+ throw new SassException('No getter function for {what}', array('{what}'=>$name));
354
+ }
355
+
356
+ public function getCache() {
357
+ return $this->cache;
358
+ }
359
+
360
+ public function getCache_location() {
361
+ return $this->cache_location;
362
+ }
363
+
364
+ public function getCss_location() {
365
+ return $this->css_location;
366
+ }
367
+
368
+ public function getDebug_info() {
369
+ return $this->debug_info;
370
+ }
371
+
372
+ public function getFilename() {
373
+ return $this->filename;
374
+ }
375
+
376
+ public function getLine() {
377
+ return $this->line;
378
+ }
379
+
380
+ public function getSource() {
381
+ return $this->source;
382
+ }
383
+
384
+ public function getLine_numbers() {
385
+ return $this->line_numbers;
386
+ }
387
+
388
+ public function getFunction_paths() {
389
+ return $this->function_paths;
390
+ }
391
+
392
+ public function getLoad_paths() {
393
+ return $this->load_paths;
394
+ }
395
+
396
+ public function getProperty_syntax() {
397
+ return $this->property_syntax;
398
+ }
399
+
400
+ public function getQuiet() {
401
+ return $this->quiet;
402
+ }
403
+
404
+ public function getStyle() {
405
+ return $this->style;
406
+ }
407
+
408
+ public function getSyntax() {
409
+ return $this->syntax;
410
+ }
411
+
412
+ public function getTemplate_location() {
413
+ return $this->template_location;
414
+ }
415
+
416
+ public function getVendor_properties() {
417
+ return $this->vendor_properties;
418
+ }
419
+
420
+ public function getOptions() {
421
+ return array(
422
+ 'cache' => $this->cache,
423
+ 'cache_location' => $this->cache_location,
424
+ 'css_location' => $this->css_location,
425
+ 'filename' => $this->filename,
426
+ 'function_paths' => $this->function_paths,
427
+ 'line' => $this->line,
428
+ 'line_numbers' => $this->line_numbers,
429
+ 'load_paths' => $this->load_paths,
430
+ 'property_syntax' => $this->property_syntax,
431
+ 'quiet' => $this->quiet,
432
+ 'style' => $this->style,
433
+ 'syntax' => $this->syntax,
434
+ 'template_location' => $this->template_location,
435
+ 'vendor_properties' => $this->vendor_properties
436
+ );
437
+ }
438
+
439
+ /**
440
+ * Parse a sass file or Sass source code and returns the CSS.
441
+ * @param string name of source file or Sass source
442
+ * @return string CSS
443
+ */
444
+ public function toCss($source, $isFile = true) {
445
+ return $this->parse($source, $isFile)->render();
446
+ }
447
+
448
+ /**
449
+ * Parse a sass file or Sass source code and
450
+ * returns the document tree that can then be rendered.
451
+ * The file will be searched for in the directories specified by the
452
+ * load_paths option.
453
+ * If caching is enabled a cached version will be used if possible or the
454
+ * compiled version cached if not.
455
+ * @param string name of source file or Sass source
456
+ * @return SassRootNode Root node of document tree
457
+ */
458
+ public function parse($source, $isFile = true) {
459
+ if ($isFile) {
460
+ $this->filename = SassFile::getFile($source, $this);
461
+
462
+ if ($isFile) {
463
+ $this->syntax = substr($this->filename, -4);
464
+ }
465
+ elseif ($this->syntax !== SassFile::SASS && $this->syntax !== SassFile::SCSS) {
466
+ throw new SassException('Invalid {what}', array('{what}'=>'syntax option'));
467
+ }
468
+
469
+ if ($this->cache) {
470
+ $cached = SassFile::getCachedFile($this->filename, $this->cache_location);
471
+ if ($cached !== false) {
472
+ return $cached;
473
+ }
474
+ }
475
+
476
+ $tree = $this->toTree(file_get_contents($this->filename));
477
+
478
+ if ($this->cache) {
479
+ SassFile::setCachedFile($tree, $this->filename, $this->cache_location);
480
+ }
481
+
482
+ return $tree;
483
+ }
484
+ else {
485
+ return $this->toTree($source);
486
+ }
487
+ }
488
+
489
+ /**
490
+ * Parse Sass source into a document tree.
491
+ * If the tree is already created return that.
492
+ * @param string Sass source
493
+ * @return SassRootNode the root of this document tree
494
+ */
495
+ private function toTree($source) {
496
+ if ($this->syntax === SassFile::SASS) {
497
+ $this->source = explode("\n", $source);
498
+ $this->setIndentChar();
499
+ }
500
+ else {
501
+ $this->source = $source;
502
+ }
503
+ unset($source);
504
+ $root = new SassRootNode($this);
505
+ $this->buildTree($root);
506
+ return $root;
507
+ }
508
+
509
+ /**
510
+ * Builds a parse tree under the parent node.
511
+ * Called recursivly until the source is parsed.
512
+ * @param SassNode the node
513
+ */
514
+ private function buildTree($parent) {
515
+ $node = $this->getNode($parent);
516
+ while (is_object($node) && $node->isChildOf($parent)) {
517
+ $parent->addChild($node);
518
+ $node = $this->buildTree($node);
519
+ }
520
+ return $node;
521
+ }
522
+
523
+ /**
524
+ * Creates and returns the next SassNode.
525
+ * The tpye of SassNode depends on the content of the SassToken.
526
+ * @return SassNode a SassNode of the appropriate type. Null when no more
527
+ * source to parse.
528
+ */
529
+ private function getNode($node) {
530
+ $token = $this->getToken();
531
+ if (empty($token)) return null;
532
+ switch (true) {
533
+ case SassDirectiveNode::isa($token):
534
+ return $this->parseDirective($token, $node);
535
+ break;
536
+ case SassCommentNode::isa($token):
537
+ return new SassCommentNode($token);
538
+ break;
539
+ case SassVariableNode::isa($token):
540
+ return new SassVariableNode($token);
541
+ break;
542
+ case SassPropertyNode::isa($token, $this->property_syntax):
543
+ return new SassPropertyNode($token, $this->property_syntax);
544
+ break;
545
+ case SassMixinDefinitionNode::isa($token):
546
+ if ($this->syntax === SassFile::SCSS) {
547
+ throw new SassException('Mixin {which} shortcut not allowed in SCSS', array('{which}'=>'definition'), $this);
548
+ }
549
+ return new SassMixinDefinitionNode($token);
550
+ break;
551
+ case SassMixinNode::isa($token):
552
+ if ($this->syntax === SassFile::SCSS) {
553
+ throw new SassException('Mixin {which} shortcut not allowed in SCSS', array('{which}'=>'include'), $this);
554
+ }
555
+ return new SassMixinNode($token);
556
+ break;
557
+ default:
558
+ return new SassRuleNode($token);
559
+ break;
560
+ } // switch
561
+ }
562
+
563
+ /**
564
+ * Returns a token object that contains the next source statement and
565
+ * meta data about it.
566
+ * @return object
567
+ */
568
+ private function getToken() {
569
+ return ($this->syntax === SassFile::SASS ? $this->sass2Token() : $this->scss2Token());
570
+ }
571
+
572
+ /**
573
+ * Returns an object that contains the next source statement and meta data
574
+ * about it from SASS source.
575
+ * Sass statements are passed over. Statements spanning multiple lines, e.g.
576
+ * CSS comments and selectors, are assembled into a single statement.
577
+ * @return object Statement token. Null if end of source.
578
+ */
579
+ private function sass2Token() {
580
+ $statement = ''; // source line being tokenised
581
+ $token = null;
582
+
583
+ while (is_null($token) && !empty($this->source)) {
584
+ while (empty($statement) && !empty($this->source)) {
585
+ $source = array_shift($this->source);
586
+ $statement = trim($source);
587
+ $this->line++;
588
+ }
589
+
590
+ if (empty($statement)) {
591
+ break;
592
+ }
593
+
594
+ $level = $this->getLevel($source);
595
+
596
+ // Comment statements can span multiple lines
597
+ if ($statement[0] === self::BEGIN_COMMENT) {
598
+ // Consume Sass comments
599
+ if (substr($statement, 0, strlen(self::BEGIN_SASS_COMMENT))
600
+ === self::BEGIN_SASS_COMMENT) {
601
+ unset($statement);
602
+ while($this->getLevel($this->source[0]) > $level) {
603
+ array_shift($this->source);
604
+ $this->line++;
605
+ }
606
+ continue;
607
+ }
608
+ // Build CSS comments
609
+ elseif (substr($statement, 0, strlen(self::BEGIN_CSS_COMMENT))
610
+ === self::BEGIN_CSS_COMMENT) {
611
+ while($this->getLevel($this->source[0]) > $level) {
612
+ $statement .= "\n" . ltrim(array_shift($this->source));
613
+ $this->line++;
614
+ }
615
+ }
616
+ else {
617
+ $this->source = $statement;
618
+ throw new SassException('Illegal comment type', array(), $this);
619
+ }
620
+ }
621
+ // Selector statements can span multiple lines
622
+ elseif (substr($statement, -1) === SassRuleNode::CONTINUED) {
623
+ // Build the selector statement
624
+ while($this->getLevel($this->source[0]) === $level) {
625
+ $statement .= ltrim(array_shift($this->source));
626
+ $this->line++;
627
+ }
628
+ }
629
+
630
+ $token = (object) array(
631
+ 'source' => $statement,
632
+ 'level' => $level,
633
+ 'filename' => $this->filename,
634
+ 'line' => $this->line - 1,
635
+ );
636
+ }
637
+ return $token;
638
+ }
639
+
640
+ /**
641
+ * Returns the level of the line.
642
+ * Used for .sass source
643
+ * @param string the source
644
+ * @return integer the level of the source
645
+ * @throws Exception if the source indentation is invalid
646
+ */
647
+ private function getLevel($source) {
648
+ $indent = strlen($source) - strlen(ltrim($source));
649
+ $level = $indent/$this->indentSpaces;
650
+ if (!is_int($level) ||
651
+ preg_match("/[^{$this->indentChar}]/", substr($source, 0, $indent))) {
652
+ $this->source = $source;
653
+ throw new SassException('Invalid indentation', array(), $this);
654
+ }
655
+ return $level;
656
+ }
657
+
658
+ /**
659
+ * Returns an object that contains the next source statement and meta data
660
+ * about it from SCSS source.
661
+ * @return object Statement token. Null if end of source.
662
+ */
663
+ private function scss2Token() {
664
+ static $srcpos = 0; // current position in the source stream
665
+ static $srclen; // the length of the source stream
666
+
667
+ $statement = '';
668
+ $token = null;
669
+ if (empty($srclen)) {
670
+ $srclen = strlen($this->source);
671
+ }
672
+ while (is_null($token) && $srcpos < $srclen) {
673
+ $c = $this->source[$srcpos++];
674
+ switch ($c) {
675
+ case self::BEGIN_COMMENT:
676
+ if (substr($this->source, $srcpos-1, strlen(self::BEGIN_SASS_COMMENT))
677
+ === self::BEGIN_SASS_COMMENT) {
678
+ while ($this->source[$srcpos++] !== "\n");
679
+ $statement .= "\n";
680
+ }
681
+ elseif (substr($this->source, $srcpos-1, strlen(self::BEGIN_CSS_COMMENT))
682
+ === self::BEGIN_CSS_COMMENT) {
683
+ if (ltrim($statement)) {
684
+ throw new SassException('Invalid {what}', array('{what}'=>'comment'), (object) array(
685
+ 'source' => $statement,
686
+ 'filename' => $this->filename,
687
+ 'line' => $this->line,
688
+ ));
689
+ }
690
+ $statement .= $c.$this->source[$srcpos++];
691
+ while (substr($this->source, $srcpos, strlen(self::END_CSS_COMMENT))
692
+ !== self::END_CSS_COMMENT) {
693
+ $statement .= $this->source[$srcpos++];
694
+ }
695
+ $srcpos += strlen(self::END_CSS_COMMENT);
696
+ $token = $this->createToken($statement.self::END_CSS_COMMENT);
697
+ }
698
+ else {
699
+ $statement .= $c;
700
+ }
701
+ break;
702
+ case self::DOUBLE_QUOTE:
703
+ case self::SINGLE_QUOTE:
704
+ $statement .= $c;
705
+ while ($this->source[$srcpos] !== $c) {
706
+ $statement .= $this->source[$srcpos++];
707
+ }
708
+ $statement .= $this->source[$srcpos++];
709
+ break;
710
+ case self::BEGIN_INTERPOLATION:
711
+ $statement .= $c;
712
+ if (substr($this->source, $srcpos-1, strlen(self::BEGIN_INTERPOLATION_BLOCK))
713
+ === self::BEGIN_INTERPOLATION_BLOCK) {
714
+ while ($this->source[$srcpos] !== self::END_BLOCK) {
715
+ $statement .= $this->source[$srcpos++];
716
+ }
717
+ $statement .= $this->source[$srcpos++];
718
+ }
719
+ break;
720
+ case self::BEGIN_BLOCK:
721
+ case self::END_BLOCK:
722
+ case self::END_STATEMENT:
723
+ $token = $this->createToken($statement . $c);
724
+ if (is_null($token)) $statement = '';
725
+ break;
726
+ default:
727
+ $statement .= $c;
728
+ break;
729
+ }
730
+ }
731
+
732
+ if (is_null($token))
733
+ $srclen = $srcpos = 0;
734
+
735
+ return $token;
736
+ }
737
+
738
+ /**
739
+ * Returns an object that contains the source statement and meta data about
740
+ * it.
741
+ * If the statement is just and end block we update the meta data and return null.
742
+ * @param string source statement
743
+ * @return SassToken
744
+ */
745
+ private function createToken($statement) {
746
+ static $level = 0;
747
+
748
+ $this->line += substr_count($statement, "\n");
749
+ $statement = trim($statement);
750
+ if (substr($statement, 0, strlen(self::BEGIN_CSS_COMMENT)) !== self::BEGIN_CSS_COMMENT) {
751
+ $statement = str_replace(array("\n","\r"), '', $statement);
752
+ }
753
+ $last = substr($statement, -1);
754
+ // Trim the statement removing whitespace, end statement (;), begin block ({), and (unless the statement ends in an interpolation block) end block (})
755
+ $statement = rtrim($statement, ' '.self::BEGIN_BLOCK.self::END_STATEMENT);
756
+ $statement = (preg_match('/#\{.+?\}$/i', $statement) ? $statement : rtrim($statement, self::END_BLOCK));
757
+ $token = ($statement ? (object) array(
758
+ 'source' => $statement,
759
+ 'level' => $level,
760
+ 'filename' => $this->filename,
761
+ 'line' => $this->line,
762
+ ) : null);
763
+ $level += ($last === self::BEGIN_BLOCK ? 1 : ($last === self::END_BLOCK ? -1 : 0));
764
+ return $token;
765
+ }
766
+
767
+ /**
768
+ * Parses a directive
769
+ * @param SassToken token to parse
770
+ * @param SassNode parent node
771
+ * @return SassNode a Sass directive node
772
+ */
773
+ private function parseDirective($token, $parent) {
774
+ switch (SassDirectiveNode::extractDirective($token)) {
775
+ case '@extend':
776
+ return new SassExtendNode($token);
777
+ break;
778
+ case '@mixin':
779
+ return new SassMixinDefinitionNode($token);
780
+ break;
781
+ case '@include':
782
+ return new SassMixinNode($token);
783
+ break;
784
+ case '@import':
785
+ if ($this->syntax == SassFile::SASS) {
786
+ $i = 0;
787
+ $source = '';
788
+ while (!empty($this->source) && empty($source)) {
789
+ $source = $this->source[$i++];
790
+ }
791
+ if (!empty($source) && $this->getLevel($source) > $token->level) {
792
+ throw new SassException('Nesting not allowed beneath {what}', array('{what}'=>'@import directive'), $token);
793
+ }
794
+ }
795
+ return new SassImportNode($token);
796
+ break;
797
+ case '@for':
798
+ return new SassForNode($token);
799
+ break;
800
+ case '@if':
801
+ return new SassIfNode($token);
802
+ break;
803
+ case '@else': // handles else and else if directives
804
+ return new SassElseNode($token);
805
+ break;
806
+ case '@do':
807
+ case '@while':
808
+ return new SassWhileNode($token);
809
+ break;
810
+ case '@debug':
811
+ return new SassDebugNode($token);
812
+ break;
813
+ case '@warn':
814
+ return new SassDebugNode($token, true);
815
+ break;
816
+ default:
817
+ return new SassDirectiveNode($token);
818
+ break;
819
+ }
820
+ }
821
+
822
+ /**
823
+ * Determine the indent character and indent spaces.
824
+ * The first character of the first indented line determines the character.
825
+ * If this is a space the number of spaces determines the indentSpaces; this
826
+ * is always 1 if the indent character is a tab.
827
+ * Only used for .sass files.
828
+ * @throws SassException if the indent is mixed or
829
+ * the indent character can not be determined
830
+ */
831
+ private function setIndentChar() {
832
+ foreach ($this->source as $l=>$source) {
833
+ if (!empty($source) && in_array($source[0], $this->indentChars)) {
834
+ $this->indentChar = $source[0];
835
+ for ($i = 0, $len = strlen($source); $i < $len && $source[$i] == $this->indentChar; $i++);
836
+ if ($i < $len && in_array($source[$i], $this->indentChars)) {
837
+ $this->line = ++$l;
838
+ $this->source = $source;
839
+ throw new SassException('Mixed indentation not allowed', array(), $this);
840
+ }
841
+ $this->indentSpaces = ($this->indentChar == ' ' ? $i : 1);
842
+ return;
843
+ }
844
+ } // foreach
845
+ $this->indentChar = ' ';
846
+ $this->indentSpaces = 2;
847
+ }
848
+ }