middleman-core 3.0.0.beta.2 → 3.0.0.beta.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (240) hide show
  1. data/features/cli_extension.feature +13 -0
  2. data/features/{cli.feature → cli_init.feature} +1 -10
  3. data/features/directory_index.feature +29 -1
  4. data/features/dynamic_pages.feature +1 -0
  5. data/features/extensionless_text_files.feature +0 -2
  6. data/features/front-matter.feature +17 -1
  7. data/features/frontmatter_page_settings.feature +16 -1
  8. data/features/helpers_relative_link_to.feature +68 -0
  9. data/features/unicode_filenames.feature +14 -0
  10. data/fixtures/csspie/config.rb +0 -0
  11. data/fixtures/csspie/source/stylesheets/PIE.htc +96 -0
  12. data/fixtures/dynamic-pages-app/config.rb +3 -0
  13. data/fixtures/frontmatter-app/source/front-matter-auto.erb +6 -0
  14. data/fixtures/frontmatter-app/source/front-matter.html.erb +2 -0
  15. data/fixtures/frontmatter-app/source/json-front-matter-2.php.erb +7 -0
  16. data/fixtures/frontmatter-app/source/json-front-matter-auto.erb +6 -0
  17. data/fixtures/frontmatter-app/source/json-front-matter.html.erb +6 -0
  18. data/fixtures/unicode-filenames-app/config.rb +1 -0
  19. data/fixtures/unicode-filenames-app/source/snowmen-rule-/342/230/203.html +4 -0
  20. data/lib/middleman-core/application.rb +43 -335
  21. data/lib/middleman-core/cli/build.rb +11 -4
  22. data/lib/middleman-core/cli/bundler.rb +40 -0
  23. data/lib/middleman-core/cli/extension.rb +36 -0
  24. data/lib/middleman-core/cli/server.rb +2 -2
  25. data/lib/middleman-core/cli.rb +2 -6
  26. data/lib/middleman-core/core_extensions/assets.rb +35 -31
  27. data/lib/middleman-core/core_extensions/builder.rb +14 -9
  28. data/lib/middleman-core/core_extensions/data.rb +150 -145
  29. data/lib/middleman-core/core_extensions/default_helpers.rb +159 -97
  30. data/lib/middleman-core/core_extensions/extensions.rb +103 -97
  31. data/lib/middleman-core/core_extensions/external_helpers.rb +27 -23
  32. data/lib/middleman-core/core_extensions/file_watcher.rb +140 -110
  33. data/lib/middleman-core/core_extensions/front_matter.rb +155 -175
  34. data/lib/middleman-core/core_extensions/i18n.rb +111 -102
  35. data/lib/middleman-core/core_extensions/rendering.rb +293 -295
  36. data/lib/middleman-core/core_extensions/request.rb +338 -0
  37. data/lib/middleman-core/core_extensions/routing.rb +72 -68
  38. data/lib/middleman-core/core_extensions/show_exceptions.rb +23 -18
  39. data/lib/middleman-core/core_extensions.rb +39 -0
  40. data/lib/middleman-core/extensions/directory_indexes.rb +1 -4
  41. data/lib/middleman-core/extensions/lorem.rb +10 -3
  42. data/lib/middleman-core/extensions.rb +2 -64
  43. data/lib/middleman-core/preview_server.rb +157 -0
  44. data/lib/middleman-core/sitemap/extensions/ignores.rb +73 -68
  45. data/lib/middleman-core/sitemap/extensions/on_disk.rb +65 -58
  46. data/lib/middleman-core/sitemap/extensions/proxies.rb +86 -75
  47. data/lib/middleman-core/sitemap/extensions/traversal.rb +68 -61
  48. data/lib/middleman-core/sitemap/resource.rb +123 -102
  49. data/lib/middleman-core/sitemap/store.rb +170 -149
  50. data/lib/middleman-core/sitemap.rb +57 -57
  51. data/lib/middleman-core/step_definitions/server_steps.rb +13 -3
  52. data/lib/middleman-core/templates/extension/Gemfile +4 -0
  53. data/lib/middleman-core/templates/extension/Rakefile +12 -0
  54. data/lib/middleman-core/templates/extension/features/support/env.rb +4 -0
  55. data/lib/middleman-core/templates/extension/gemspec +24 -0
  56. data/lib/middleman-core/templates/extension/lib/lib.rb +49 -0
  57. data/lib/middleman-core/templates/extension/lib/middleman_extension.rb +1 -0
  58. data/lib/middleman-core/templates/shared/gitignore +14 -0
  59. data/lib/middleman-core/templates.rb +14 -8
  60. data/lib/middleman-core/util.rb +31 -9
  61. data/lib/middleman-core/version.rb +1 -1
  62. data/lib/middleman-core.rb +6 -4
  63. data/middleman-core.gemspec +4 -6
  64. metadata +62 -203
  65. data/lib/middleman-core/vendor/padrino-core-0.10.6/.document +0 -5
  66. data/lib/middleman-core/vendor/padrino-core-0.10.6/.gitignore +0 -22
  67. data/lib/middleman-core/vendor/padrino-core-0.10.6/.yardopts +0 -1
  68. data/lib/middleman-core/vendor/padrino-core-0.10.6/LICENSE.txt +0 -20
  69. data/lib/middleman-core/vendor/padrino-core-0.10.6/README.rdoc +0 -294
  70. data/lib/middleman-core/vendor/padrino-core-0.10.6/Rakefile +0 -5
  71. data/lib/middleman-core/vendor/padrino-core-0.10.6/bin/padrino +0 -9
  72. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/application/rendering.rb +0 -292
  73. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/application/routing.rb +0 -943
  74. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/application/showexceptions.rb +0 -20
  75. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/application.rb +0 -269
  76. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/caller.rb +0 -53
  77. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/cli/adapter.rb +0 -24
  78. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/cli/base.rb +0 -150
  79. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/cli/console.rb +0 -20
  80. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/cli/rake.rb +0 -24
  81. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/cli/rake_tasks.rb +0 -59
  82. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/command.rb +0 -38
  83. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/images/404.png +0 -0
  84. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/images/500.png +0 -0
  85. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/loader.rb +0 -211
  86. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/cs.yml +0 -34
  87. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/da.yml +0 -34
  88. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/de.yml +0 -34
  89. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/en.yml +0 -34
  90. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/es.yml +0 -34
  91. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/fr.yml +0 -34
  92. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/hu.yml +0 -34
  93. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/it.yml +0 -40
  94. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/ja.yml +0 -34
  95. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/lv.yml +0 -34
  96. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/nl.yml +0 -34
  97. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/no.yml +0 -35
  98. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/pl.yml +0 -34
  99. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/pt_br.yml +0 -40
  100. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/ru.yml +0 -35
  101. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/tr.yml +0 -34
  102. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/uk.yml +0 -34
  103. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/zh_cn.yml +0 -34
  104. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/locale/zh_tw.yml +0 -34
  105. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/logger.rb +0 -428
  106. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/mounter.rb +0 -224
  107. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/reloader.rb +0 -254
  108. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/router.rb +0 -98
  109. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/server.rb +0 -79
  110. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/support_lite.rb +0 -199
  111. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/tasks.rb +0 -21
  112. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/version.rb +0 -20
  113. data/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core.rb +0 -152
  114. data/lib/middleman-core/vendor/padrino-core-0.10.6/padrino-core.gemspec +0 -38
  115. data/lib/middleman-core/vendor/padrino-core-0.10.6/test/fixtures/apps/.components +0 -6
  116. data/lib/middleman-core/vendor/padrino-core-0.10.6/test/fixtures/apps/.gitignore +0 -7
  117. data/lib/middleman-core/vendor/padrino-core-0.10.6/test/fixtures/apps/complex.rb +0 -32
  118. data/lib/middleman-core/vendor/padrino-core-0.10.6/test/fixtures/apps/simple.rb +0 -33
  119. data/lib/middleman-core/vendor/padrino-core-0.10.6/test/fixtures/dependencies/a.rb +0 -9
  120. data/lib/middleman-core/vendor/padrino-core-0.10.6/test/fixtures/dependencies/b.rb +0 -4
  121. data/lib/middleman-core/vendor/padrino-core-0.10.6/test/fixtures/dependencies/c.rb +0 -1
  122. data/lib/middleman-core/vendor/padrino-core-0.10.6/test/fixtures/dependencies/circular/e.rb +0 -13
  123. data/lib/middleman-core/vendor/padrino-core-0.10.6/test/fixtures/dependencies/circular/f.rb +0 -2
  124. data/lib/middleman-core/vendor/padrino-core-0.10.6/test/fixtures/dependencies/circular/g.rb +0 -2
  125. data/lib/middleman-core/vendor/padrino-core-0.10.6/test/fixtures/dependencies/d.rb +0 -4
  126. data/lib/middleman-core/vendor/padrino-core-0.10.6/test/helper.rb +0 -83
  127. data/lib/middleman-core/vendor/padrino-core-0.10.6/test/mini_shoulda.rb +0 -45
  128. data/lib/middleman-core/vendor/padrino-core-0.10.6/test/test_application.rb +0 -108
  129. data/lib/middleman-core/vendor/padrino-core-0.10.6/test/test_core.rb +0 -77
  130. data/lib/middleman-core/vendor/padrino-core-0.10.6/test/test_dependencies.rb +0 -44
  131. data/lib/middleman-core/vendor/padrino-core-0.10.6/test/test_filters.rb +0 -278
  132. data/lib/middleman-core/vendor/padrino-core-0.10.6/test/test_locale.rb +0 -21
  133. data/lib/middleman-core/vendor/padrino-core-0.10.6/test/test_logger.rb +0 -154
  134. data/lib/middleman-core/vendor/padrino-core-0.10.6/test/test_mounter.rb +0 -177
  135. data/lib/middleman-core/vendor/padrino-core-0.10.6/test/test_reloader_complex.rb +0 -75
  136. data/lib/middleman-core/vendor/padrino-core-0.10.6/test/test_reloader_simple.rb +0 -98
  137. data/lib/middleman-core/vendor/padrino-core-0.10.6/test/test_rendering.rb +0 -461
  138. data/lib/middleman-core/vendor/padrino-core-0.10.6/test/test_restful_routing.rb +0 -33
  139. data/lib/middleman-core/vendor/padrino-core-0.10.6/test/test_router.rb +0 -146
  140. data/lib/middleman-core/vendor/padrino-core-0.10.6/test/test_routing.rb +0 -1680
  141. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/.document +0 -5
  142. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/.gitignore +0 -21
  143. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/.yardopts +0 -1
  144. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/LICENSE.txt +0 -20
  145. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/README.rdoc +0 -239
  146. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/Rakefile +0 -5
  147. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/asset_tag_helpers.rb +0 -417
  148. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/form_builder/abstract_form_builder.rb +0 -251
  149. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/form_builder/standard_form_builder.rb +0 -43
  150. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/form_helpers.rb +0 -787
  151. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/format_helpers.rb +0 -381
  152. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/cs.yml +0 -103
  153. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/da.yml +0 -91
  154. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/de.yml +0 -81
  155. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/en.yml +0 -103
  156. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/es.yml +0 -103
  157. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/fr.yml +0 -80
  158. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/hu.yml +0 -103
  159. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/it.yml +0 -89
  160. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/ja.yml +0 -103
  161. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/lv.yml +0 -103
  162. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/nl.yml +0 -82
  163. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/no.yml +0 -91
  164. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/pl.yml +0 -95
  165. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/pt_br.yml +0 -103
  166. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/ru.yml +0 -103
  167. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/tr.yml +0 -103
  168. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/uk.yml +0 -103
  169. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/zh_cn.yml +0 -104
  170. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/zh_tw.yml +0 -103
  171. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/number_helpers.rb +0 -288
  172. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/output_helpers/abstract_handler.rb +0 -98
  173. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/output_helpers/erb_handler.rb +0 -79
  174. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/output_helpers/haml_handler.rb +0 -63
  175. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/output_helpers/slim_handler.rb +0 -81
  176. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/output_helpers.rb +0 -175
  177. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/render_helpers.rb +0 -60
  178. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/tag_helpers.rb +0 -260
  179. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers/translation_helpers.rb +0 -38
  180. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers.rb +0 -59
  181. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/padrino-helpers.gemspec +0 -27
  182. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/app.rb +0 -73
  183. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/capture_concat.erb +0 -14
  184. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/capture_concat.haml +0 -12
  185. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/capture_concat.slim +0 -13
  186. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/content_for.erb +0 -14
  187. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/content_for.haml +0 -12
  188. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/content_for.slim +0 -12
  189. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/content_tag.erb +0 -11
  190. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/content_tag.haml +0 -9
  191. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/content_tag.slim +0 -9
  192. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/current_engine.erb +0 -5
  193. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/current_engine.haml +0 -5
  194. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/current_engine.slim +0 -5
  195. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/fields_for.erb +0 -20
  196. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/fields_for.haml +0 -15
  197. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/fields_for.slim +0 -15
  198. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/form_for.erb +0 -72
  199. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/form_for.haml +0 -59
  200. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/form_for.slim +0 -59
  201. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/form_tag.erb +0 -86
  202. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/form_tag.haml +0 -70
  203. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/form_tag.slim +0 -70
  204. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/link_to.erb +0 -5
  205. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/link_to.haml +0 -4
  206. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/link_to.slim +0 -4
  207. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/mail_to.erb +0 -3
  208. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/mail_to.haml +0 -3
  209. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/mail_to.slim +0 -3
  210. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/meta_tag.erb +0 -3
  211. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/meta_tag.haml +0 -3
  212. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/meta_tag.slim +0 -3
  213. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/partials/_erb.erb +0 -1
  214. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/partials/_haml.haml +0 -1
  215. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/partials/_slim.slim +0 -1
  216. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/simple_partial.erb +0 -1
  217. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/simple_partial.haml +0 -1
  218. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/markup_app/views/simple_partial.slim +0 -1
  219. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/render_app/app.rb +0 -50
  220. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/render_app/views/current_engine.haml +0 -5
  221. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/render_app/views/current_engines/_erb.erb +0 -1
  222. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/render_app/views/current_engines/_haml.haml +0 -1
  223. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/render_app/views/current_engines/_slim.slim +0 -1
  224. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/render_app/views/erb/test.erb +0 -1
  225. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/render_app/views/explicit_engine.haml +0 -5
  226. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/render_app/views/haml/test.haml +0 -1
  227. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/render_app/views/template/_user.haml +0 -7
  228. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/render_app/views/template/haml_template.haml +0 -1
  229. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/fixtures/render_app/views/template/some_template.haml +0 -2
  230. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/helper.rb +0 -66
  231. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/test_asset_tag_helpers.rb +0 -328
  232. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/test_form_builder.rb +0 -1106
  233. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/test_form_helpers.rb +0 -770
  234. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/test_format_helpers.rb +0 -227
  235. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/test_locale.rb +0 -20
  236. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/test_number_helpers.rb +0 -139
  237. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/test_output_helpers.rb +0 -153
  238. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/test_render_helpers.rb +0 -76
  239. data/lib/middleman-core/vendor/padrino-helpers-0.10.6/test/test_tag_helpers.rb +0 -106
  240. data/lib/middleman-core/watcher.rb +0 -196
@@ -1,294 +0,0 @@
1
- = Padrino (padrino-core)
2
-
3
- Padrino is the godfather of Sinatra.
4
-
5
- == Preface
6
-
7
- Padrino is a ruby framework built upon the excellent {Sinatra Microframework}[http://www.sinatrarb.com].
8
- Sinatra is a DSL for creating simple web applications in Ruby with speed and minimal effort.
9
- This framework tries hard to make it as fun and easy as possible to code much more advanced web applications by
10
- building upon the Sinatra philosophies and foundation.
11
-
12
- == Introduction
13
-
14
- Many people love Sinatra's simplicity and lightweight but often quickly come to miss a great deal
15
- of functionality provided by other web frameworks such as Rails when building non-trivial applications.
16
-
17
- Our goal with this framework is to match the essence of Sinatra and at the same time create a standard library
18
- of tools, helpers and components that will make Sinatra suitable for more complex applications.
19
-
20
- Here is a brief overview of functionality provided by the Padrino framework:
21
-
22
- Agnostic:: Full support for many popular testing, templating, mocking, and data storage choices.
23
- Generators:: Create Padrino applications, models, controllers i.e: padrino-gen project.
24
- Mountable:: Unlike other ruby frameworks, principally designed for mounting multiple apps.
25
- Routing:: Full url named routes, named params, respond_to support, before/after filter support.
26
- Tag Helpers:: View helpers such as: tag, content_tag, input_tag.
27
- Asset Helpers:: View helpers such as: link_to, image_tag, javascript_include_tag.
28
- Form Helpers:: Builder support such as: form_tag, form_for, field_set_tag, text_field.
29
- Text Helpers:: Useful formatting like: time_ago_in_words, js_escape_html, sanitize_html.
30
- Mailer:: Fast and simple delivery support for sending emails (akin to ActionMailer).
31
- Admin:: Builtin Admin interface (like Django)
32
- Logging:: Provide a unified logger that can interact with your ORM or any library.
33
- Reloading:: Automatically reloads server code during development.
34
- Localization:: Full support of I18n language localization and can auto-set user's locale.
35
-
36
- Keep in mind, the user will be able to pull in these components
37
- {seperately into existing Sinatra applications}[http://www.padrinorb.com/guides/standalone-usage-in-sinatra]
38
- or use them altogether for a comprehensive upgrade to Sinatra (a full-stack Padrino application).
39
-
40
- == Installation
41
-
42
- To install the padrino framework, simply grab the latest version from gemcutter:
43
-
44
- $ sudo gem install padrino
45
-
46
- This will install the necessary padrino gems to get you started.
47
- Now you are ready to use this gem to enhance your sinatra projects or to create new Padrino applications.
48
-
49
- For a more detailed look at Padrino installation,
50
- check out the {Installation Guide}[http://www.padrinorb.com/guides/installation].
51
-
52
- == Usage
53
-
54
- Padrino is a framework which builds on the existing functionality and Sinatra and provides a variety of
55
- additional tools and helpers to build upon that foundation. This README and Padrino documentation in general will focus
56
- on the enhancements to the core Sinatra functionality. To use Padrino, one should be familiar with the basic
57
- usage of Sinatra itself.
58
-
59
- Please check out the
60
- {Understanding Sinatra}[http://www.padrinorb.com/guides/underlying-sinatra-overview] guide
61
- to learn more about these fundamentals.
62
-
63
- For information on how to use a specific gem in isolation within an existing Sinatra project, checkout the guide for
64
- {Using Padrino in Sinatra}[http://www.padrinorb.com/guides/standalone-usage-in-sinatra].
65
-
66
- == Getting Started
67
-
68
- Once a developer understands Sinatra, Padrino is quite easy to get comfortable with since Padrino is simply a superset
69
- of existing Sinatra Functionality! Best way to get started with building Padrino applications is to read following resources:
70
-
71
- * {Blog Tutorial}[http://www.padrinorb.com/guides/blog-tutorial] - Step-by-step guide to building a blog application with Padrino.
72
- * {Quick Overview}[http://www.padrinorb.com/guides/basic-projects] - Outlines basic generation commands.
73
- * {Padrino Examples}[http://www.padrinorb.com/guides/examples] - List of known Padrino applications which can serve as examples.
74
-
75
- == Enhanced Base Application (padrino-core)
76
-
77
- Sinatra has support for classes which can be extended to create an application: <tt>Sinatra::Base</tt> and <tt>Sinatra::Application</tt>
78
- These classes can be extended in order to create a Sinatra web application. These classes provide support for all the basic
79
- functionality afforded by Sinatra.
80
-
81
- Padrino has support for an enhanced base application class <tt>Padrino::Application</tt>. <tt>Padrino::Application</tt>
82
- expands the capabilities of Sinatra::Application and automatically provides the resulting application access to all of
83
- the padrino framework's functionalities.
84
-
85
- === Simple Application Definition
86
-
87
- Let us first take a look at the simplest possible Padrino application:
88
-
89
- # app.rb
90
- PADRINO_ROOT = File.dirname(__FILE__) unless defined? PADRINO_ROOT
91
- require 'padrino'
92
- Padrino.load!
93
-
94
- class SimpleApp < Padrino::Application
95
- get '/' do
96
- 'Hello world'
97
- end
98
-
99
- # and for read better we can divide with controllers
100
- controller '/admin' do
101
- get '/foo' do
102
- 'Url is /admin/foo'
103
- end
104
- end
105
- end
106
-
107
- === Enhanced Route Definitions and Controllers
108
-
109
- For a complete overview of the Padrino routing and controller system,
110
- check out the {Routing and Controller guide}[http://www.padrinorb.com/guides/controllers].
111
-
112
- Suppose we wanted to add additional routes to our Padrino application, and we want to organize the routes
113
- within a more structured layout. Simply add a <tt>controllers</tt> or <tt>app/controllers</tt> folder and create a file as such:
114
-
115
- # Simple Example
116
- SimpleApp.controllers do
117
- get "/test" do
118
- "Text to return"
119
- end
120
- end
121
-
122
- You can also do more complex route alias definitions:
123
-
124
- # app/controllers/example.rb
125
- SimpleApp.controllers :posts do
126
- get :index do
127
- ...
128
- end
129
-
130
- get :show, :with => :id do
131
- # url generated is '/posts/show/:id'
132
- # access params[:id]
133
- end
134
- end
135
-
136
- as well as mapping the route aliases to an explicit url:
137
-
138
- # app/controllers/example.rb
139
- SimpleApp.controllers do
140
- get :index, :map => '/index' do
141
- ...
142
- end
143
-
144
- get :account, :map => '/the/accounts/:name/and/:id' do
145
- # access params[:name] and params[:index]
146
- end
147
- end
148
-
149
- and even configure the respond_to for each route:
150
-
151
- # app/controllers/example.rb
152
- SimpleApp.controllers :admin do
153
- get :show, :with => :id, :provides => :js do
154
- "Url is /admin/show/#{params[:id]}.#{params[:format]}"
155
- end
156
-
157
- get :other, with => [:id, :name], respond_to => [:html, :json] do
158
- case content_type
159
- when :js then ... end
160
- when :json then ... end
161
- end
162
- end
163
- end
164
-
165
- or auto lookup for current locale or content_type
166
-
167
- # app/controllers/example.rb
168
- SimpleApp.controllers :admin do
169
- get :show, :with => :id, :provides => [html, :js] do
170
- render "admin/show"
171
- end
172
- end
173
-
174
- When you visit :+show+ and your I18n.locale == :ru Padrino try to look for "admin/show.ru.js.*" if nothing match that path
175
- they try "admin/show.ru.*" then "admin/show.js.*" if none match return "admin/show.erb" (or other engine i.e. haml)
176
-
177
- For a complete overview of the routing and controller system, check out the
178
- {Routing and Controller guide}[http://www.padrinorb.com/guides/controllers].
179
-
180
- === Rendering
181
-
182
- Unlike Sinatra, Padrino supports automatic template lookups such as:
183
-
184
- # searches for 'account/index.{erb,haml,...}
185
- render 'account/index'
186
-
187
- This render does not require any template engine to be specified and will choose the first one that is discovered.
188
- The existing render function works as well if an engine type should be specified:
189
-
190
- # example.haml
191
- render :haml, 'account/index'
192
-
193
- For a complete overview of the Padrino rendering system, check out the
194
- {Routing and Controller guide}[http://www.padrinorb.com/guides/controllers].
195
-
196
- === Layout
197
-
198
- With Padrino you can (like rails do) use for your custom layout, disable it
199
-
200
- class SimpleApp < Padrino::Application
201
-
202
- # Disable layouts
203
- disable layout
204
-
205
- # Use the layout located in views/layouts/custom.haml
206
- layout :custom
207
-
208
- For a complete overview of the layout functionality,
209
- check out the {Routing and Controller guide}[http://www.padrinorb.com/guides/controllers].
210
-
211
- === Mounting Applications
212
-
213
- Padrino applications are all automatically mountable into other Padrino projects. This means that a given Padrino
214
- project directory can easily mount multiple applications. This allows for better organization of complex applications,
215
- re-usable applications that can be applied (i.e admin, auth, blog) and even more flexibility.
216
-
217
- You can think of mountable applications as a 'full-featured' merb slice or rails engine. Instead of a separate construct,
218
- any application can simply be packaged and mounted into another project.
219
-
220
- Padrino stores application mounting information by default within <tt>config/apps.rb</tt>. This file is intended
221
- to keep all information regarding what applications are mounted to which uri's.
222
-
223
- For a complete look at mounting applications within a Padrino project,
224
- check out the guide on {Mounting Applications}[http://www.padrinorb.com/guides/mounting-applications].
225
-
226
- === Auto Load Paths
227
-
228
- Padrino also intelligently supports requiring useful files within your application automatically and provides
229
- functionality for easily splitting up your application into separate files. Padrino automatically requires <tt>config/database.rb</tt>
230
- as a convention for establishing database connection. Also, any files within the <tt>lib</tt> folder will be required
231
- automatically by Padrino.
232
-
233
- For a complete overview of auto-loaded paths within Padrino,
234
- check out the {Padrino Development Guide}[http://www.padrinorb.com/guides/development-and-terminal-commands].
235
-
236
- === Application Logging
237
-
238
- Padrino also supports robust logging capabilities. By default, logging information will
239
- go to the STDOUT in development (for use in a console) and in an environment-specific log file <tt>log/development.log</tt>
240
- in test and production environments.
241
-
242
- To use the logger within a Padrino application, simply refer to the <tt>logger</tt> method accessible
243
- within your app and any controller or views:
244
-
245
- # controllers/example.rb
246
- SimpleApp.controllers do
247
- get("/test") { logger.info "This is a test" }
248
- end
249
-
250
- For a complete overview of Padrino logger functionality, check out the
251
- {Padrino Development Guide}[http://www.padrinorb.com/guides/development-and-terminal-commands].
252
-
253
- === Development Reloader
254
-
255
- Padrino applications also have the enabled ability to automatically reload all changing application files without
256
- the need to restart the server. Through the use of a customized Rack middleware, all files on the 'load path'
257
- are monitored and reloaded whenever changes are applied.
258
-
259
- This makes rapid development much easier and provides a better alternative to 'shotgun' or 'rerun'
260
- which requires the application server to be restarted which makes requests take much longer to complete.
261
-
262
- For a complete overview of code reloading in development,
263
- check out the {Padrino Development Guide}[http://www.padrinorb.com/guides/development-and-terminal-commands].
264
-
265
- === Terminal Commands
266
-
267
- Padrino also comes equipped with multiple useful terminal commands which can be activated to perform
268
- common tasks such as starting / stopping the application, executing the unit tests or activating an irb session.
269
-
270
- The following commands are available:
271
-
272
- # starts the app server (non-daemonized)
273
- $ padrino start
274
- # starts the app server (daemonized) with given port, environment and adapter
275
- $ padrino start -d -p 3000 -e development -a thin
276
-
277
- # Stops a daemonized app server
278
- $ padrino stop
279
-
280
- # Bootup the Padrino console (irb)
281
- $ padrino console
282
-
283
- # Run/List tasks
284
- $ padrino rake
285
-
286
- You can also create custom rake tasks as well. Using these commands can simplify common tasks
287
- making development that much smoother.
288
-
289
- For a complete overview of Padrino terminal commands, check out the
290
- {Padrino Commands Guide}[http://www.padrinorb.com/guides/development-and-terminal-commands].
291
-
292
- == Copyright
293
-
294
- Copyright (c) 2011 Padrino. See LICENSE for details.
@@ -1,5 +0,0 @@
1
- # coding:utf-8
2
- RAKE_ROOT = __FILE__
3
-
4
- require 'rubygems'
5
- require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper')
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'rubygems' unless defined?(Gem)
3
- require 'bundler/setup' if %w(Gemfile .components).all? { |f| File.exist?(f) }
4
-
5
- padrino_core_path = File.expand_path('../../lib', __FILE__)
6
- $:.unshift(padrino_core_path) if File.directory?(padrino_core_path) && !$:.include?(padrino_core_path)
7
-
8
- require 'padrino-core/cli/base'
9
- Padrino::Cli::Base.start(ARGV)
@@ -1,292 +0,0 @@
1
- require 'padrino-core/support_lite' unless defined?(SupportLite)
2
-
3
- module Padrino
4
- ##
5
- # Padrino enhances the Sinatra 'render' method to have support for
6
- # automatic template engine detection, enhanced layout functionality,
7
- # locale enabled rendering, among other features.
8
- #
9
- module Rendering
10
- ##
11
- # Exception responsible for when an expected template did not exist.
12
- #
13
- class TemplateNotFound < RuntimeError
14
- end
15
-
16
- ##
17
- # This is an array of file patterns to ignore. If your editor add a
18
- # suffix during editing to your files please add it like:
19
- #
20
- # @example
21
- # Padrino::Rendering::IGNORE_FILE_PATTERN << /~$/
22
- #
23
- IGNORE_FILE_PATTERN = [
24
- /~$/ # This is for Gedit
25
- ] unless defined?(IGNORE_FILE_PATTERN)
26
-
27
- ##
28
- # Default rendering options used in the #render-method.
29
- #
30
- DEFAULT_RENDERING_OPTIONS = { :strict_format => false, :raise_exceptions => true } unless defined?(DEFAULT_RENDERING_OPTIONS)
31
-
32
- class << self
33
- ##
34
- # Main class that register this extension.
35
- #
36
- def registered(app)
37
- app.send(:include, InstanceMethods)
38
- app.extend(ClassMethods)
39
- end
40
- alias :included :registered
41
- end
42
-
43
- ##
44
- # Class methods responsible for rendering templates as part of a request.
45
- #
46
- module ClassMethods
47
- ##
48
- # Use layout like rails does or if a block given then like sinatra.
49
- # If used without a block, sets the current layout for the route.
50
- #
51
- # By default, searches in your:
52
- #
53
- # +app+/+views+/+layouts+/+application+.(+haml+|+erb+|+xxx+)
54
- # +app+/+views+/+layout_name+.(+haml+|+erb+|+xxx+)
55
- #
56
- # If you define +layout+ :+custom+ then searches for your layouts in
57
- # +app+/+views+/+layouts+/+custom+.(+haml+|+erb+|+xxx+)
58
- # +app+/+views+/+custom+.(+haml+|+erb+|+xxx+)
59
- #
60
- # @param [Symbol] name (:layout)
61
- # The layout to use.
62
- #
63
- # @yield []
64
- #
65
- def layout(name=:layout, &block)
66
- return super(name, &block) if block_given?
67
- @layout = name
68
- end
69
-
70
- ##
71
- # Returns the cached template file to render for a given url, content_type and locale.
72
- #
73
- # @param [Array<template_path, content_type, locale>] render_options
74
- #
75
- def fetch_template_file(render_options)
76
- (@_cached_templates ||= {})[render_options]
77
- end
78
-
79
- ##
80
- # Caches the template file for the given rendering options
81
- #
82
- # @param [String] template_file
83
- # The path of the template file.
84
- #
85
- # @param [Array<template_path, content_type, locale>] render_options
86
- #
87
- def cache_template_file!(template_file, render_options)
88
- (@_cached_templates ||= {})[render_options] = template_file || []
89
- end
90
-
91
- ##
92
- # Returns the cached layout path.
93
- #
94
- # @param [Symbol, nil] given_layout
95
- # The requested layout.
96
- #
97
- def fetch_layout_path(given_layout=nil)
98
- layout_name = given_layout || @layout || :application
99
- @_cached_layout ||= {}
100
- cached_layout_path = @_cached_layout[layout_name]
101
- return cached_layout_path if cached_layout_path
102
- has_layout_at_root = Dir["#{views}/#{layout_name}.*"].any?
103
- layout_path = has_layout_at_root ? layout_name.to_sym : File.join('layouts', layout_name.to_s).to_sym
104
- @_cached_layout[layout_name] = layout_path unless reload_templates?
105
- layout_path
106
- end
107
- end
108
-
109
- # Instance methods that allow enhanced rendering to function properly in Padrino.
110
- module InstanceMethods
111
- attr_reader :current_engine
112
-
113
- ##
114
- # Get/Set the content_type
115
- #
116
- # @param [String, nil] type
117
- # The Content-Type to use.
118
- #
119
- # @param [Symbol, nil] type.
120
- # Look and parse the given symbol to the matched Content-Type.
121
- #
122
- # @param [Hash] params
123
- # Additional params to append to the Content-Type.
124
- #
125
- # @example
126
- # case content_type
127
- # when :js then do_some
128
- # when :css then do_another
129
- # end
130
- #
131
- # content_type :js
132
- # # => set the response with 'application/javascript' Content-Type
133
- # content_type 'text/html'
134
- #
135
- # # => set directly the Content-Type to 'text/html'
136
- #
137
- def content_type(type=nil, params={})
138
- unless type.nil?
139
- super(type, params)
140
- @_content_type = type
141
- end
142
- @_content_type
143
- end
144
-
145
- private
146
- ##
147
- # Enhancing Sinatra render functionality for:
148
- #
149
- # * Using layout similar to rails
150
- # * Use render 'path/to/my/template' (without symbols)
151
- # * Use render 'path/to/my/template' (with engine lookup)
152
- # * Use render 'path/to/template.haml' (with explicit engine lookup)
153
- # * Use render 'path/to/template', :layout => false
154
- # * Use render 'path/to/template', :layout => false, :engine => 'haml'
155
- # * Use render { :a => 1, :b => 2, :c => 3 } # => return a json string
156
- #
157
- def render(engine, data=nil, options={}, locals={}, &block)
158
- # If engine is a hash then render data converted to json
159
- content_type(:json, :charset => 'utf-8') and return engine.to_json if engine.is_a?(Hash)
160
-
161
- # If engine is nil, ignore engine parameter and shift up all arguments
162
- # render nil, "index", { :layout => true }, { :localvar => "foo" }
163
- engine, data, options = data, options, locals if engine.nil? && data
164
-
165
- # Data is a hash of options when no engine isn't explicit
166
- # render "index", { :layout => true }, { :localvar => "foo" }
167
- # Data is options, and options is locals in this case
168
- data, options, locals = nil, data, options if data.is_a?(Hash)
169
-
170
- # If data is unassigned then this is a likely a template to be resolved
171
- # This means that no engine was explicitly defined
172
- data, engine = *resolve_template(engine, options.dup) if data.nil?
173
-
174
- # Setup root
175
- root = settings.respond_to?(:root) ? settings.root : ""
176
-
177
- # Use @layout if it exists
178
- options[:layout] = @layout if options[:layout].nil?
179
-
180
- # Resolve layouts similar to in Rails
181
- if (options[:layout].nil? || options[:layout] == true) && !settings.templates.has_key?(:layout)
182
- layout_path, layout_engine = *resolved_layout
183
- options[:layout] = layout_path || false # We need to force layout false so sinatra don't try to render it
184
- options[:layout] = false unless layout_engine == engine # TODO allow different layout engine
185
- options[:layout_engine] = layout_engine || engine if options[:layout]
186
- elsif options[:layout].present?
187
- options[:layout] = settings.fetch_layout_path(options[:layout] || @layout)
188
- end
189
-
190
- # Cleanup the template
191
- @current_engine, engine_was = engine, @current_engine
192
- @_out_buf, _buf_was = "", @_out_buf
193
-
194
- # Pass arguments to Sinatra render method
195
- super(engine, data, options.dup, locals, &block)
196
- ensure
197
- @current_engine = engine_was
198
- @_out_buf = _buf_was
199
- end
200
-
201
- ##
202
- # Returns the located layout tuple to be used for the rendered template
203
- # (if available).
204
- #
205
- # @example
206
- # resolve_layout
207
- # # => ["/layouts/custom", :erb]
208
- # # => [nil, nil]
209
- #
210
- def resolved_layout
211
- located_layout = resolve_template(settings.fetch_layout_path, :raise_exceptions => false, :strict_format => true)
212
- located_layout ? located_layout : [nil, nil]
213
- end
214
-
215
- ##
216
- # Returns the template path and engine that match content_type (if present),
217
- # I18n.locale.
218
- #
219
- # @param [String] template_path
220
- # The path of the template.
221
- #
222
- # @param [Hash] options
223
- # Additional options.
224
- #
225
- # @option options [Boolean] :strict_format (false)
226
- # The resolved template must match the content_type of the request.
227
- #
228
- # @option options [Boolean] :raise_exceptions (false)
229
- # Raises a {TemplateNotFound} exception if the template cannot be located.
230
- #
231
- # @return [Array<Symbol, Symbol>]
232
- # The path and format of the template.
233
- #
234
- # @raise [TemplateNotFound]
235
- # The template could not be found.
236
- #
237
- # @example
238
- # get "/foo", :provides => [:html, :js] do; render 'path/to/foo'; end
239
- # # If you request "/foo.js" with I18n.locale == :ru => [:"/path/to/foo.ru.js", :erb]
240
- # # If you request "/foo" with I18n.locale == :de => [:"/path/to/foo.de.haml", :haml]
241
- #
242
- def resolve_template(template_path, options={})
243
- began_at = Time.now
244
- # Fetch cached template for rendering options
245
- template_path = template_path.to_s[0] == ?/ ? template_path.to_s : "/#{template_path}"
246
- rendering_options = [template_path, content_type, locale]
247
- cached_template = settings.fetch_template_file(rendering_options)
248
- if cached_template
249
- logger.debug :cached, began_at, cached_template[0] if settings.logging? && defined?(logger)
250
- return cached_template
251
- end
252
-
253
- # Resolve view path and options
254
- options.reverse_merge!(DEFAULT_RENDERING_OPTIONS)
255
- view_path = options.delete(:views) || settings.views || "./views"
256
- target_extension = File.extname(template_path)[1..-1] || "none" # explicit template extension
257
- template_path = template_path.chomp(".#{target_extension}")
258
-
259
- # Generate potential template candidates
260
- templates = Dir[File.join(view_path, template_path) + ".*"].map do |file|
261
- template_engine = File.extname(file)[1..-1].to_sym # retrieves engine extension
262
- template_file = file.sub(view_path, '').chomp(".#{template_engine}").to_sym # retrieves template filename
263
- [template_file, template_engine] unless IGNORE_FILE_PATTERN.any? { |pattern| template_engine.to_s =~ pattern }
264
- end
265
-
266
- # Check if we have a simple content type
267
- simple_content_type = [:html, :plain].include?(content_type)
268
-
269
- # Resolve final template to render
270
- located_template =
271
- templates.find { |file, e| file.to_s == "#{template_path}.#{locale}.#{content_type}" } ||
272
- templates.find { |file, e| file.to_s == "#{template_path}.#{locale}" && simple_content_type } ||
273
- templates.find { |file, e| File.extname(file.to_s) == ".#{target_extension}" or e.to_s == target_extension.to_s } ||
274
- templates.find { |file, e| file.to_s == "#{template_path}.#{content_type}" } ||
275
- templates.find { |file, e| file.to_s == "#{template_path}" && simple_content_type } ||
276
- (!options[:strict_format] && templates.first) # If not strict, fall back to the first located template
277
-
278
- raise TemplateNotFound, "Template '#{template_path}' not found in '#{view_path}'!" if !located_template && options[:raise_exceptions]
279
- settings.cache_template_file!(located_template, rendering_options) unless settings.reload_templates?
280
- logger.debug :template, began_at, located_template[0] if located_template && settings.logging? && defined?(logger)
281
- located_template
282
- end
283
-
284
- ##
285
- # Return the I18n.locale if I18n is defined.
286
- #
287
- def locale
288
- I18n.locale if defined?(I18n)
289
- end
290
- end # InstanceMethods
291
- end # Rendering
292
- end # Padrino