brakeman 7.1.2 → 8.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (271) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +48 -0
  3. data/README.md +1 -1
  4. data/bundle/load.rb +7 -7
  5. data/bundle/ruby/3.2.0/gems/{csv-3.3.5 → csv-3.3.6}/NEWS.md +39 -1
  6. data/bundle/ruby/3.2.0/gems/{csv-3.3.5 → csv-3.3.6}/README.md +1 -1
  7. data/bundle/ruby/3.2.0/gems/{csv-3.3.5 → csv-3.3.6}/lib/csv/parser.rb +7 -2
  8. data/bundle/ruby/3.2.0/gems/{csv-3.3.5 → csv-3.3.6}/lib/csv/row.rb +26 -2
  9. data/bundle/ruby/3.2.0/gems/{csv-3.3.5 → csv-3.3.6}/lib/csv/version.rb +1 -1
  10. data/bundle/ruby/3.2.0/gems/{csv-3.3.5 → csv-3.3.6}/lib/csv.rb +30 -58
  11. data/bundle/ruby/3.2.0/gems/erubi-1.13.1/CHANGELOG +111 -0
  12. data/bundle/ruby/3.2.0/gems/{erubis-2.7.0 → erubi-1.13.1}/MIT-LICENSE +1 -0
  13. data/bundle/ruby/3.2.0/gems/erubi-1.13.1/README.rdoc +151 -0
  14. data/bundle/ruby/3.2.0/gems/erubi-1.13.1/lib/erubi/capture_block.rb +91 -0
  15. data/bundle/ruby/3.2.0/gems/erubi-1.13.1/lib/erubi/capture_end.rb +58 -0
  16. data/bundle/ruby/3.2.0/gems/erubi-1.13.1/lib/erubi.rb +299 -0
  17. data/bundle/ruby/3.2.0/gems/parallel-1.28.0/lib/parallel/version.rb +4 -0
  18. data/bundle/ruby/3.2.0/gems/{parallel-1.27.0 → parallel-1.28.0}/lib/parallel.rb +11 -0
  19. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/io/ansi.rb +6 -4
  20. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/io/windows.rb +49 -23
  21. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/io.rb +8 -2
  22. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/line_editor.rb +49 -21
  23. data/bundle/ruby/3.2.0/gems/reline-0.7.0/lib/reline/version.rb +3 -0
  24. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline.rb +10 -9
  25. data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/CHANGES +8 -2
  26. data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/Gemfile +5 -2
  27. data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/LICENSE +1 -1
  28. data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/README.jp.md +10 -12
  29. data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/README.md +21 -26
  30. data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/embedded.rb +1 -1
  31. data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/logic_less/context.rb +4 -3
  32. data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/splat/builder.rb +18 -19
  33. data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/version.rb +1 -1
  34. data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/CHANGES +8 -0
  35. data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/README.md +1 -1
  36. data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filters/static_analyzer.rb +1 -1
  37. data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filters/string_splitter.rb +61 -5
  38. data/bundle/ruby/3.2.0/gems/temple-0.10.6/lib/temple/parser_engine.rb +34 -0
  39. data/bundle/ruby/3.2.0/gems/temple-0.10.6/lib/temple/static_analyzer.rb +148 -0
  40. data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/version.rb +1 -1
  41. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/COPYING +1 -1
  42. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/asciidoc.rb +12 -5
  43. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/babel.rb +5 -0
  44. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/builder.rb +4 -0
  45. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/coffee.rb +14 -4
  46. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/commonmarker.rb +65 -0
  47. data/bundle/ruby/3.2.0/gems/tilt-2.8.0/lib/tilt/csv.rb +63 -0
  48. data/bundle/ruby/3.2.0/gems/tilt-2.8.0/lib/tilt/erb.rb +130 -0
  49. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/erubi.rb +41 -8
  50. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/etanni.rb +7 -0
  51. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/haml.rb +67 -1
  52. data/bundle/ruby/3.2.0/gems/tilt-2.8.0/lib/tilt/kramdown.rb +59 -0
  53. data/bundle/ruby/3.2.0/gems/tilt-2.8.0/lib/tilt/liquid.rb +93 -0
  54. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/livescript.rb +11 -4
  55. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/mapping.rb +8 -8
  56. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/markaby.rb +11 -2
  57. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/nokogiri.rb +13 -2
  58. data/bundle/ruby/3.2.0/gems/tilt-2.8.0/lib/tilt/pandoc.rb +81 -0
  59. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/pipeline.rb +6 -1
  60. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/plain.rb +5 -1
  61. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/prawn.rb +17 -6
  62. data/bundle/ruby/3.2.0/gems/tilt-2.8.0/lib/tilt/radius.rb +96 -0
  63. data/bundle/ruby/3.2.0/gems/tilt-2.8.0/lib/tilt/rdiscount.rb +82 -0
  64. data/bundle/ruby/3.2.0/gems/tilt-2.8.0/lib/tilt/rdoc.rb +41 -0
  65. data/bundle/ruby/3.2.0/gems/tilt-2.8.0/lib/tilt/redcarpet.rb +73 -0
  66. data/bundle/ruby/3.2.0/gems/tilt-2.8.0/lib/tilt/redcloth.rb +40 -0
  67. data/bundle/ruby/3.2.0/gems/tilt-2.8.0/lib/tilt/rst-pandoc.rb +33 -0
  68. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/sass.rb +16 -3
  69. data/bundle/ruby/3.2.0/gems/tilt-2.8.0/lib/tilt/slim.rb +18 -0
  70. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/string.rb +10 -2
  71. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/template.rb +5 -5
  72. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/typescript.rb +5 -0
  73. data/bundle/ruby/3.2.0/gems/tilt-2.8.0/lib/tilt/yajl.rb +91 -0
  74. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt.rb +1 -2
  75. data/lib/brakeman/app_tree.rb +7 -2
  76. data/lib/brakeman/checks/check_eol_rails.rb +2 -1
  77. data/lib/brakeman/checks/check_eol_ruby.rb +1 -0
  78. data/lib/brakeman/checks/check_execute.rb +23 -19
  79. data/lib/brakeman/checks/check_model_attributes.rb +1 -1
  80. data/lib/brakeman/checks/check_render.rb +1 -27
  81. data/lib/brakeman/checks/check_render_rce.rb +43 -0
  82. data/lib/brakeman/checks/check_session_settings.rb +1 -1
  83. data/lib/brakeman/checks/check_sql.rb +4 -3
  84. data/lib/brakeman/checks.rb +31 -25
  85. data/lib/brakeman/commandline.rb +17 -5
  86. data/lib/brakeman/file_parser.rb +3 -2
  87. data/lib/brakeman/logger.rb +265 -0
  88. data/lib/brakeman/options.rb +6 -11
  89. data/lib/brakeman/parsers/rails_erubi.rb +82 -0
  90. data/lib/brakeman/parsers/template_parser.rb +7 -15
  91. data/lib/brakeman/processor.rb +2 -2
  92. data/lib/brakeman/processors/base_processor.rb +13 -6
  93. data/lib/brakeman/processors/controller_alias_processor.rb +1 -1
  94. data/lib/brakeman/processors/controller_processor.rb +3 -3
  95. data/lib/brakeman/processors/{erubis_template_processor.rb → erubi_template_procesor.rb} +3 -3
  96. data/lib/brakeman/processors/gem_processor.rb +1 -1
  97. data/lib/brakeman/processors/haml_template_processor.rb +3 -1
  98. data/lib/brakeman/processors/lib/rails2_config_processor.rb +4 -3
  99. data/lib/brakeman/processors/lib/rails2_route_processor.rb +1 -1
  100. data/lib/brakeman/processors/lib/rails3_config_processor.rb +10 -1
  101. data/lib/brakeman/processors/lib/render_helper.rb +4 -2
  102. data/lib/brakeman/processors/lib/render_path.rb +1 -1
  103. data/lib/brakeman/processors/model_processor.rb +1 -1
  104. data/lib/brakeman/report/ignore/config.rb +1 -1
  105. data/lib/brakeman/scanner.rb +33 -51
  106. data/lib/brakeman/tracker/collection.rb +12 -2
  107. data/lib/brakeman/tracker/config.rb +17 -13
  108. data/lib/brakeman/tracker/constants.rb +17 -2
  109. data/lib/brakeman/tracker/controller.rb +1 -1
  110. data/lib/brakeman/tracker.rb +7 -15
  111. data/lib/brakeman/version.rb +1 -1
  112. data/lib/brakeman.rb +109 -55
  113. metadata +182 -210
  114. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/CHANGES.txt +0 -828
  115. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/README.txt +0 -102
  116. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/contrib/erubis +0 -3468
  117. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/contrib/erubis-run.rb +0 -132
  118. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/contrib/inline-require +0 -179
  119. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/context.rb +0 -83
  120. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/converter.rb +0 -357
  121. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ec.rb +0 -117
  122. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ecpp.rb +0 -113
  123. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ejava.rb +0 -110
  124. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ejavascript.rb +0 -119
  125. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/enhanced.rb +0 -126
  126. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/eperl.rb +0 -95
  127. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ephp.rb +0 -99
  128. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/eruby.rb +0 -125
  129. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/escheme.rb +0 -114
  130. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/optimized.rb +0 -127
  131. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine.rb +0 -120
  132. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/enhancer.rb +0 -723
  133. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/error.rb +0 -23
  134. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/evaluator.rb +0 -88
  135. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/generator.rb +0 -85
  136. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/helper.rb +0 -47
  137. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/helpers/rails_form_helper.rb +0 -197
  138. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/helpers/rails_helper.rb +0 -353
  139. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/local-setting.rb +0 -9
  140. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/main.rb +0 -516
  141. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/preprocessing.rb +0 -58
  142. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/tiny.rb +0 -144
  143. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/util.rb +0 -22
  144. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis.rb +0 -73
  145. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/setup.rb +0 -1331
  146. data/bundle/ruby/3.2.0/gems/parallel-1.27.0/lib/parallel/version.rb +0 -4
  147. data/bundle/ruby/3.2.0/gems/reline-0.6.3/lib/reline/version.rb +0 -3
  148. data/bundle/ruby/3.2.0/gems/temple-0.10.4/lib/temple/static_analyzer.rb +0 -78
  149. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/creole.rb +0 -16
  150. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/csv.rb +0 -53
  151. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/erb.rb +0 -65
  152. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/kramdown.rb +0 -13
  153. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/liquid.rb +0 -37
  154. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/pandoc.rb +0 -39
  155. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/radius.rb +0 -41
  156. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/rdiscount.rb +0 -23
  157. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/rdoc.rb +0 -11
  158. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/redcarpet.rb +0 -31
  159. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/redcloth.rb +0 -13
  160. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/rst-pandoc.rb +0 -10
  161. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/slim.rb +0 -5
  162. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/yajl.rb +0 -81
  163. data/lib/brakeman/parsers/erubis_patch.rb +0 -11
  164. data/lib/brakeman/parsers/rails2_erubis.rb +0 -9
  165. data/lib/brakeman/parsers/rails2_xss_plugin_erubis.rb +0 -52
  166. data/lib/brakeman/parsers/rails3_erubis.rb +0 -85
  167. data/bundle/ruby/3.2.0/gems/{csv-3.3.5 → csv-3.3.6}/LICENSE.txt +0 -0
  168. data/bundle/ruby/3.2.0/gems/{csv-3.3.5 → csv-3.3.6}/lib/csv/core_ext/array.rb +0 -0
  169. data/bundle/ruby/3.2.0/gems/{csv-3.3.5 → csv-3.3.6}/lib/csv/core_ext/string.rb +0 -0
  170. data/bundle/ruby/3.2.0/gems/{csv-3.3.5 → csv-3.3.6}/lib/csv/fields_converter.rb +0 -0
  171. data/bundle/ruby/3.2.0/gems/{csv-3.3.5 → csv-3.3.6}/lib/csv/input_record_separator.rb +0 -0
  172. data/bundle/ruby/3.2.0/gems/{csv-3.3.5 → csv-3.3.6}/lib/csv/table.rb +0 -0
  173. data/bundle/ruby/3.2.0/gems/{csv-3.3.5 → csv-3.3.6}/lib/csv/writer.rb +0 -0
  174. data/bundle/ruby/3.2.0/gems/{parallel-1.27.0 → parallel-1.28.0}/MIT-LICENSE.txt +0 -0
  175. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/BSDL +0 -0
  176. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/COPYING +0 -0
  177. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/README.md +0 -0
  178. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/config.rb +0 -0
  179. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/face.rb +0 -0
  180. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/history.rb +0 -0
  181. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/io/dumb.rb +0 -0
  182. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/key_actor/base.rb +0 -0
  183. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/key_actor/composite.rb +0 -0
  184. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/key_actor/emacs.rb +2 -2
  185. /data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/key_actor/vi_command.rb +0 -0
  186. /data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/key_actor/vi_insert.rb +0 -0
  187. /data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/key_actor.rb +0 -0
  188. /data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/key_stroke.rb +0 -0
  189. /data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/kill_ring.rb +0 -0
  190. /data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/unicode/east_asian_width.rb +0 -0
  191. /data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/unicode.rb +0 -0
  192. /data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/license_of_rb-readline +0 -0
  193. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/code_attributes.rb +0 -0
  194. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/command.rb +0 -0
  195. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/controls.rb +0 -0
  196. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/do_inserter.rb +0 -0
  197. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/end_inserter.rb +0 -0
  198. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/engine.rb +0 -0
  199. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/erb_converter.rb +0 -0
  200. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/filter.rb +0 -0
  201. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/grammar.rb +0 -0
  202. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/include.rb +0 -0
  203. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/interpolation.rb +0 -0
  204. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/logic_less/filter.rb +0 -0
  205. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/logic_less.rb +0 -0
  206. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/parser.rb +0 -0
  207. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/railtie.rb +0 -0
  208. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/smart/escaper.rb +0 -0
  209. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/smart/filter.rb +0 -0
  210. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/smart/parser.rb +0 -0
  211. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/smart.rb +0 -0
  212. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/splat/filter.rb +0 -0
  213. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/template.rb +0 -0
  214. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/translator.rb +0 -0
  215. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim.rb +0 -0
  216. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/slim.gemspec +0 -0
  217. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/EXPRESSIONS.md +0 -0
  218. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/Gemfile +0 -0
  219. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/LICENSE +0 -0
  220. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/engine.rb +0 -0
  221. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/erb/engine.rb +0 -0
  222. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/erb/parser.rb +0 -0
  223. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/erb/template.rb +0 -0
  224. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/erb/trimming.rb +0 -0
  225. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/exceptions.rb +0 -0
  226. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filter.rb +0 -0
  227. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filters/ambles.rb +0 -0
  228. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filters/code_merger.rb +0 -0
  229. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filters/control_flow.rb +0 -0
  230. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filters/dynamic_inliner.rb +0 -0
  231. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filters/dynamic_merger.rb +0 -0
  232. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filters/encoding.rb +0 -0
  233. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filters/eraser.rb +0 -0
  234. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filters/escapable.rb +0 -0
  235. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filters/multi_flattener.rb +0 -0
  236. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filters/remove_bom.rb +0 -0
  237. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filters/static_merger.rb +0 -0
  238. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filters/validator.rb +0 -0
  239. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/generator.rb +0 -0
  240. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/generators/array.rb +0 -0
  241. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/generators/array_buffer.rb +0 -0
  242. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/generators/erb.rb +0 -0
  243. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/generators/rails_output_buffer.rb +0 -0
  244. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/generators/string_buffer.rb +0 -0
  245. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/grammar.rb +0 -0
  246. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/html/attribute_merger.rb +0 -0
  247. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/html/attribute_remover.rb +0 -0
  248. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/html/attribute_sorter.rb +0 -0
  249. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/html/dispatcher.rb +0 -0
  250. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/html/fast.rb +0 -0
  251. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/html/filter.rb +0 -0
  252. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/html/pretty.rb +0 -0
  253. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/html/safe.rb +0 -0
  254. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/map.rb +0 -0
  255. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/mixins/dispatcher.rb +0 -0
  256. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/mixins/engine_dsl.rb +0 -0
  257. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/mixins/grammar_dsl.rb +0 -0
  258. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/mixins/options.rb +0 -0
  259. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/mixins/template.rb +0 -0
  260. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/parser.rb +0 -0
  261. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/templates/rails.rb +0 -0
  262. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/templates/tilt.rb +0 -0
  263. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/templates.rb +0 -0
  264. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/utils.rb +0 -0
  265. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple.rb +0 -0
  266. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/temple.gemspec +0 -0
  267. /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/_emacs_org.rb +0 -0
  268. /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/_handlebars.rb +0 -0
  269. /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/_jbuilder.rb +0 -0
  270. /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/_org.rb +0 -0
  271. /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/cli.rb +0 -0
@@ -228,13 +228,13 @@ module Slim
228
228
  end
229
229
 
230
230
  # These engines are executed at compile time, embedded ruby is interpolated
231
+ register :asciidoc, InterpolateTiltEngine
231
232
  register :markdown, InterpolateTiltEngine
232
233
  register :textile, InterpolateTiltEngine
233
234
  register :rdoc, InterpolateTiltEngine
234
235
 
235
236
  # These engines are executed at compile time
236
237
  register :coffee, JavaScriptEngine, engine: TiltEngine
237
- register :less, TagEngine, tag: :style, engine: TiltEngine
238
238
  register :sass, TagEngine, :pretty, tag: :style, engine: SassEngine
239
239
  register :scss, TagEngine, :pretty, tag: :style, engine: SassEngine
240
240
 
@@ -27,7 +27,8 @@ module Slim
27
27
  end
28
28
 
29
29
  def section(name)
30
- if dict = scope[name]
30
+ dict = scope[name]
31
+ if dict && !(dict.respond_to?(:empty?) && dict.empty?)
31
32
  if !dict.respond_to?(:has_key?) && dict.respond_to?(:each)
32
33
  new_scope do
33
34
  dict.each do |d|
@@ -42,8 +43,8 @@ module Slim
42
43
  end
43
44
 
44
45
  def inverted_section(name)
45
- value = scope[name]
46
- yield if !value || (value.respond_to?(:empty?) && value.empty?)
46
+ dict = scope[name]
47
+ yield if !dict || (dict.respond_to?(:empty?) && dict.empty?)
47
48
  end
48
49
 
49
50
  def to_s
@@ -48,25 +48,7 @@ module Slim
48
48
  tag = @attrs.delete('tag').to_s
49
49
  tag = @options[:default_tag] if tag.empty?
50
50
  if block
51
- # This is a bit of a hack to get a universal capturing.
52
- #
53
- # TODO: Add this as a helper somewhere to solve these capturing issues
54
- # once and for all.
55
- #
56
- # If we have Slim capturing disabled and the scope defines the method `capture` (i.e. Rails)
57
- # we use this method to capture the content.
58
- #
59
- # otherwise we just use normal Slim capturing (yield).
60
- #
61
- # See https://github.com/slim-template/slim/issues/591
62
- # https://github.com/slim-template/slim#helpers-capturing-and-includes
63
- #
64
- content =
65
- if @options[:disable_capture] && (scope = block.binding.eval('self')).respond_to?(:capture)
66
- scope.capture(&block)
67
- else
68
- yield
69
- end
51
+ content = capture_block_content(&block)
70
52
  "<#{tag}#{build_attrs}>#{content}</#{tag}>"
71
53
  else
72
54
  "<#{tag}#{build_attrs} />"
@@ -90,6 +72,23 @@ module Slim
90
72
 
91
73
  private
92
74
 
75
+ # Captures block content using the appropriate capturing mechanism.
76
+ #
77
+ # If we have Slim capturing disabled and the scope defines the method `capture` (i.e. Rails)
78
+ # we use this method to capture the content.
79
+ #
80
+ # Otherwise we just use normal Slim capturing (yield).
81
+ #
82
+ # See https://github.com/slim-template/slim/issues/591
83
+ # https://github.com/slim-template/slim#helpers-capturing-and-includes
84
+ def capture_block_content(&block)
85
+ if @options[:disable_capture] && (scope = block.binding.eval('self')).respond_to?(:capture)
86
+ scope.capture(&block)
87
+ else
88
+ yield
89
+ end
90
+ end
91
+
93
92
  def hyphen_attr(name, escape, value)
94
93
  if Hash === value
95
94
  if @options[:hyphen_underscore_attrs]
@@ -2,5 +2,5 @@
2
2
  module Slim
3
3
  # Slim version string
4
4
  # @api public
5
- VERSION = '5.2.1'
5
+ VERSION = '5.2.2'
6
6
  end
@@ -1,3 +1,11 @@
1
+ 0.10.6
2
+
3
+ * Make StaticAnalyzer recognize shorthand syntax as dynamic (#149)
4
+
5
+ 0.10.5
6
+
7
+ * Allow using prism as the parser engine (#156)
8
+
1
9
  0.10.4
2
10
 
3
11
  * Fix Ruby 3.4 compatibility (#152)
@@ -1,7 +1,7 @@
1
1
  Temple
2
2
  ======
3
3
 
4
- [![test](https://github.com/judofyr/temple/actions/workflows/test.yml/badge.svg)](https://github.com/judofyr/temple/actions/workflows/test.yml) [![Code Climate](https://codeclimate.com/github/judofyr/temple.svg)](https://codeclimate.com/github/judofyr/temple) [![Gem Version](https://badge.fury.io/rb/temple.svg)](https://rubygems.org/gems/temple) [![Yard Docs](https://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/gems/temple/frames)
4
+ [![test](https://github.com/judofyr/temple/actions/workflows/test.yml/badge.svg)](https://github.com/judofyr/temple/actions/workflows/test.yml) [![Maintainability](https://qlty.sh/gh/judofyr/projects/temple/maintainability.svg)](https://qlty.sh/gh/judofyr/projects/temple) [![Gem Version](https://badge.fury.io/rb/temple.svg)](https://rubygems.org/gems/temple) [![Yard Docs](https://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/gems/temple/frames)
5
5
 
6
6
  Temple is an abstraction and a framework for compiling templates to pure Ruby.
7
7
  It's all about making it easier to experiment, implement and optimize template
@@ -4,7 +4,7 @@ module Temple
4
4
  # Convert [:dynamic, code] to [:static, text] if code is static Ruby expression.
5
5
  class StaticAnalyzer < Filter
6
6
  def call(exp)
7
- # Optimize only when Ripper is available.
7
+ # Optimize only when a parser engine is available.
8
8
  if ::Temple::StaticAnalyzer.available?
9
9
  super
10
10
  else
@@ -1,14 +1,70 @@
1
1
  # frozen_string_literal: true
2
- begin
3
- require 'ripper'
4
- rescue LoadError
5
- end
2
+ require 'temple/parser_engine'
6
3
 
7
4
  module Temple
8
5
  module Filters
9
6
  # Compile [:dynamic, "foo#{bar}"] to [:multi, [:static, 'foo'], [:dynamic, 'bar']]
10
7
  class StringSplitter < Filter
11
- if defined?(Ripper) && Ripper.respond_to?(:lex)
8
+ if PARSER_ENGINE == :prism
9
+ class << self
10
+ # `code` param must be valid string literal
11
+ def compile(code)
12
+ compiled = try_compile(code)
13
+ raise(FilterError, "Expected string literal") unless compiled
14
+ compiled
15
+ end
16
+
17
+ def try_compile(code)
18
+ result = Prism.parse(code)
19
+ return unless result.success?
20
+
21
+ stmts = result.value.statements.body
22
+ return if stmts.size != 1
23
+
24
+ stack = [stmts.first]
25
+ compiled = []
26
+
27
+ until stack.empty?
28
+ case (node = stack.pop).type
29
+ when :interpolated_string_node
30
+ stack.concat(node.parts.reverse)
31
+ when :string_node
32
+ if !(unescaped = node.unescaped).empty?
33
+ compiled << [:static, unescaped]
34
+ end
35
+ when :embedded_statements_node
36
+ if (stmts = node.statements) && !(slice = stmts.slice).empty?
37
+ compiled << [:dynamic, slice]
38
+ end
39
+ when :embedded_variable_node
40
+ compiled << [:dynamic, node.variable.slice]
41
+ else
42
+ return
43
+ end
44
+ end
45
+
46
+ compiled
47
+ end
48
+ end
49
+
50
+ def on_dynamic(code)
51
+ return [:dynamic, code] if code.include?("\n")
52
+
53
+ compiled = StringSplitter.try_compile(code)
54
+ return [:dynamic, code] unless compiled
55
+
56
+ temple = [:multi]
57
+ compiled.each do |type, content|
58
+ case type
59
+ when :static
60
+ temple << [:static, content]
61
+ when :dynamic
62
+ temple << on_dynamic(content)
63
+ end
64
+ end
65
+ temple
66
+ end
67
+ elsif PARSER_ENGINE == :ripper
12
68
  class << self
13
69
  # `code` param must be valid string literal
14
70
  def compile(code)
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Temple
4
+ temple_parser_engine = ENV['TEMPLE_PARSER_ENGINE']
5
+
6
+ prism_available =
7
+ if !temple_parser_engine || temple_parser_engine == 'prism'
8
+ begin
9
+ require 'prism'
10
+ true
11
+ rescue LoadError
12
+ end
13
+ end
14
+
15
+ ripper_available =
16
+ if !temple_parser_engine || temple_parser_engine == 'ripper'
17
+ begin
18
+ require 'ripper'
19
+ Ripper.respond_to?(:lex)
20
+ rescue LoadError
21
+ end
22
+ end
23
+
24
+ PARSER_ENGINE =
25
+ if prism_available
26
+ :prism
27
+ elsif ripper_available
28
+ :ripper
29
+ else
30
+ :none
31
+ end
32
+
33
+ private_constant :PARSER_ENGINE
34
+ end
@@ -0,0 +1,148 @@
1
+ # frozen_string_literal: true
2
+ require 'temple/parser_engine'
3
+
4
+ module Temple
5
+ module StaticAnalyzer
6
+ if PARSER_ENGINE == :prism
7
+ class << self
8
+ def available?
9
+ true
10
+ end
11
+
12
+ def static?(code)
13
+ return false if code.nil? || code.strip.empty?
14
+ (result = Prism.parse(code)).success? && static_node?(result.value)
15
+ end
16
+
17
+ def syntax_error?(code)
18
+ !Prism.parse_success?(code)
19
+ end
20
+
21
+ private
22
+
23
+ def static_node?(node)
24
+ case node.type
25
+ when :program_node
26
+ static_node?(node.statements)
27
+ when :parentheses_node
28
+ (stmts = node.body).is_a?(Prism::StatementsNode) &&
29
+ static_node?(stmts)
30
+ when :statements_node
31
+ node.body.size == 1 && static_node?(node.body.first)
32
+ when :interpolated_string_node
33
+ node.parts.all? { |part| static_node?(part) }
34
+ when :embedded_statements_node
35
+ (stmts = node.statements) && static_node?(stmts)
36
+ when :array_node
37
+ node.elements.all? { |elem| static_node?(elem) }
38
+ when :hash_node, :keyword_hash_node
39
+ node.elements.all? { |elem| static_node?(elem) }
40
+ when :assoc_node
41
+ static_node?(node.key) && static_node?(node.value)
42
+ when :string_node, :integer_node, :float_node, :imaginary_node,
43
+ :rational_node, :symbol_node, :true_node, :false_node, :nil_node
44
+ true
45
+ else
46
+ false
47
+ end
48
+ end
49
+ end
50
+ elsif PARSER_ENGINE == :ripper
51
+ STATIC_TOKENS = [
52
+ :on_tstring_beg, :on_tstring_end, :on_tstring_content,
53
+ :on_embexpr_beg, :on_embexpr_end,
54
+ :on_lbracket, :on_rbracket,
55
+ :on_qwords_beg, :on_words_sep, :on_qwords_sep,
56
+ :on_lparen, :on_rparen,
57
+ :on_lbrace, :on_rbrace, :on_label,
58
+ :on_int, :on_float, :on_imaginary,
59
+ :on_comma, :on_sp, :on_ignored_nl,
60
+ ].freeze
61
+
62
+ DYNAMIC_TOKENS = [
63
+ :on_ident, :on_period,
64
+ ].freeze
65
+
66
+ STATIC_KEYWORDS = [
67
+ 'true', 'false', 'nil',
68
+ ].freeze
69
+
70
+ STATIC_OPERATORS = [
71
+ '=>',
72
+ ].freeze
73
+
74
+ class << self
75
+ def available?
76
+ true
77
+ end
78
+
79
+ def static?(code)
80
+ return false if code.nil? || code.strip.empty? || syntax_error?(code)
81
+
82
+ Ripper.lex(code).each do |_, token, str|
83
+ case token
84
+ when *STATIC_TOKENS
85
+ # noop
86
+ when :on_kw
87
+ return false unless STATIC_KEYWORDS.include?(str)
88
+ when :on_op
89
+ return false unless STATIC_OPERATORS.include?(str)
90
+ when *DYNAMIC_TOKENS
91
+ return false
92
+ else
93
+ return false
94
+ end
95
+ end
96
+
97
+ !ShorthandSyntaxChecker.shorthand?(code)
98
+ end
99
+
100
+ def syntax_error?(code)
101
+ SyntaxChecker.new(code).parse
102
+ false
103
+ rescue SyntaxChecker::ParseError
104
+ true
105
+ end
106
+
107
+ class SyntaxChecker < Ripper
108
+ class ParseError < StandardError; end
109
+
110
+ private
111
+
112
+ def on_parse_error(*)
113
+ raise ParseError
114
+ end
115
+ end
116
+
117
+ class ShorthandSyntaxChecker < Ripper
118
+ class << self
119
+ def shorthand?(code)
120
+ instance = new(code)
121
+ instance.parse
122
+ instance.shorthand
123
+ end
124
+ end
125
+
126
+ attr_reader :shorthand
127
+
128
+ def initialize(*)
129
+ super
130
+ @shorthand = nil
131
+ end
132
+
133
+ private
134
+
135
+ def on_assoc_new(key, value)
136
+ @shorthand = true if value.nil?
137
+ end
138
+ end
139
+ end
140
+ else
141
+ class << self
142
+ def available?
143
+ false
144
+ end
145
+ end
146
+ end
147
+ end
148
+ end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Temple
3
- VERSION = '0.10.4'
3
+ VERSION = '0.10.6'
4
4
  end
@@ -1,5 +1,5 @@
1
1
  Copyright (c) 2010-2016 Ryan Tomayko <http://tomayko.com/about>
2
- Copyright (c) 2015-2023 Jeremy Evans
2
+ Copyright (c) 2015-2026 Jeremy Evans and contributors
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to
@@ -1,14 +1,21 @@
1
1
  # frozen_string_literal: true
2
- require_relative 'template'
3
- require 'asciidoctor'
4
- # AsciiDoc see: http://asciidoc.org/
5
2
 
6
- # Asciidoctor implementation for AsciiDoc see:
7
- # http://asciidoctor.github.com/
3
+ # = AsciiDoc
4
+ #
5
+ # Asciidoctor implementation for AsciiDoc
8
6
  #
9
7
  # Asciidoctor is an open source, pure-Ruby processor for
10
8
  # converting AsciiDoc documents or strings into HTML 5,
11
9
  # DocBook 4.5 and other formats.
10
+ #
11
+ # === See also
12
+ #
13
+ # * http://asciidoc.org
14
+ # * http://asciidoctor.github.com
15
+
16
+ require_relative 'template'
17
+ require 'asciidoctor'
18
+
12
19
  Tilt::AsciidoctorTemplate = Tilt::StaticTemplate.subclass do
13
20
  @options[:header_footer] = false if @options[:header_footer].nil?
14
21
  Asciidoctor.render(@data, @options)
@@ -1,4 +1,9 @@
1
1
  # frozen_string_literal: true
2
+
3
+ # = Babel
4
+ #
5
+ #
6
+
2
7
  require_relative 'template'
3
8
  require 'babel/transpiler'
4
9
 
@@ -1,4 +1,8 @@
1
1
  # frozen_string_literal: true
2
+
3
+ # = Builder
4
+ #
5
+
2
6
  require_relative 'template'
3
7
  require 'builder'
4
8
 
@@ -1,12 +1,22 @@
1
1
  # frozen_string_literal: true
2
+
3
+ # CoffeeScript / Literate CoffeeScript template implementation.
4
+ #
5
+ # CoffeeScript templates do not support object scopes, locals, or yield.
6
+ #
7
+ # === See also
8
+ #
9
+ # * http://coffeescript.org
10
+ #
11
+ # === Related modules
12
+ #
13
+ # * Tilt::CoffeeScriptTemplate
14
+ # * Tilt::CoffeeScriptLiterateTemplate
15
+
2
16
  require_relative 'template'
3
17
  require 'coffee_script'
4
18
 
5
19
  module Tilt
6
- # CoffeeScript template implementation. See:
7
- # http://coffeescript.org/
8
- #
9
- # CoffeeScript templates do not support object scopes, locals, or yield.
10
20
  class CoffeeScriptTemplate < StaticTemplate
11
21
  self.default_mime_type = 'application/javascript'
12
22
 
@@ -1,4 +1,45 @@
1
1
  # frozen_string_literal: true
2
+ #
3
+ # = Markdown (<tt>markdown</tt>, <tt>md</tt>, <tt>mkd</tt>)
4
+ #
5
+ # Markdown is a lightweight markup language, created by John Gruber
6
+ # and Aaron Swartz. For any markup that is not covered by Markdown’s syntax, HTML
7
+ # is used. Marking up plain text with Markdown markup is easy and Markdown
8
+ # formatted texts are readable.
9
+ #
10
+ # === Example
11
+ #
12
+ # Hello Markdown Templates
13
+ # ========================
14
+ #
15
+ # Hello World. This is a paragraph.
16
+ #
17
+ # === Usage
18
+ #
19
+ # To wrap a Markdown formatted document with a layout:
20
+ #
21
+ # layout = Tilt['erb'].new do
22
+ # "<!doctype html><title></title><%= yield %>"
23
+ # end
24
+ # data = Tilt['md'].new { "# hello tilt" }
25
+ # layout.render { data.render }
26
+ # # => "<!doctype html><title></title><h1>hello tilt</h1>\n"
27
+ #
28
+ # === Options
29
+ #
30
+ # ==== <tt>:smartypants => true|false</tt>
31
+ #
32
+ # Set <tt>true</tt> to enable [Smarty Pants][smartypants] style punctuation replacement.
33
+ #
34
+ # ==== <tt>:escape_html => true|false</tt>
35
+ #
36
+ # Set <tt>true</tt> disallow raw HTML in Markdown contents. HTML is converted to
37
+ # literal text by escaping <tt><</tt> characters.
38
+ #
39
+ # === See also
40
+ #
41
+ # * {Markdown Syntax Documentation}[http://daringfireball.net/projects/markdown/syntax]
42
+
2
43
  require_relative 'template'
3
44
  require 'commonmarker'
4
45
 
@@ -9,14 +50,24 @@ if defined?(::Commonmarker)
9
50
  parse_opts = [
10
51
  :smart,
11
52
  :default_info_string,
53
+ :relaxed_tasklist_matching,
54
+ :relaxed_autolinks,
55
+ :leave_footnote_definitions,
56
+ :ignore_setext,
12
57
  ].freeze
13
58
  render_opts = [
14
59
  :hardbreaks,
15
60
  :github_pre_lang,
61
+ :full_info_string,
16
62
  :width,
17
63
  :unsafe,
18
64
  :escape,
19
65
  :sourcepos,
66
+ :escaped_char_spans,
67
+ :ignore_empty_links,
68
+ :gfm_quirks,
69
+ :prefer_fenced,
70
+ :tasklist_classes,
20
71
  ].freeze
21
72
  exts = [
22
73
  :strikethrough,
@@ -27,9 +78,23 @@ if defined?(::Commonmarker)
27
78
  :superscript,
28
79
  :header_ids,
29
80
  :footnotes,
81
+ :inline_footnotes,
30
82
  :description_lists,
31
83
  :front_matter_delimiter,
84
+ :multiline_block_quotes,
85
+ :math_dollars,
86
+ :math_code,
32
87
  :shortcodes,
88
+ :wikilinks_title_before_pipe,
89
+ :wikilinks_title_after_pipe,
90
+ :underline,
91
+ :spoiler,
92
+ :greentext,
93
+ :subscript,
94
+ :subtext,
95
+ :alerts,
96
+ :cjk_friendly_emphasis,
97
+ :highlight,
33
98
  ].freeze
34
99
 
35
100
  Tilt::CommonMarkerTemplate = Tilt::StaticTemplate.subclass do
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ # = CSV
4
+ #
5
+ # CSV Template implementation.
6
+ #
7
+ # === Example
8
+ #
9
+ # # Example of csv template
10
+ # tpl = <<-EOS
11
+ # # header
12
+ # csv << ['NAME', 'ID']
13
+ #
14
+ # # data rows
15
+ # @people.each do |person|
16
+ # csv << [person[:name], person[:id]]
17
+ # end
18
+ # EOS
19
+ #
20
+ # @people = [
21
+ # {:name => "Joshua Peek", :id => 1},
22
+ # {:name => "Ryan Tomayko", :id => 2},
23
+ # {:name => "Simone Carletti", :id => 3}
24
+ # ]
25
+ #
26
+ # template = Tilt::CSVTemplate.new { tpl }
27
+ # template.render(self)
28
+ #
29
+ # === See also
30
+ #
31
+ # * http://ruby-doc.org/stdlib/libdoc/csv/rdoc/CSV.html
32
+ #
33
+ # === Related module
34
+ #
35
+ # * Tilt::CSVTemplate
36
+
37
+ require_relative 'template'
38
+ require 'csv'
39
+
40
+ module Tilt
41
+
42
+ class CSVTemplate < Template
43
+ self.default_mime_type = 'text/csv'
44
+
45
+ def prepare
46
+ @outvar = @options.delete(:outvar) || '_csvout'
47
+ end
48
+
49
+ def precompiled_template(locals)
50
+ <<-RUBY
51
+ #{@outvar} = CSV.generate(**#{@options}) do |csv|
52
+ #{@data}
53
+ end
54
+ RUBY
55
+ end
56
+
57
+ def precompiled(locals)
58
+ source, offset = super
59
+ [source, offset + 1]
60
+ end
61
+
62
+ end
63
+ end