diff --git a/app.rb b/app.rb index 7a0adf9..750d2c2 100644 --- a/app.rb +++ b/app.rb @@ -8,6 +8,10 @@ class TonTonWeb::App < Sinatra::Base # Renders a view by the filename without the extension (without a predefined render) # TODO: pass this to tonton-web code def render_any template_name, base_dir, options = {} + for extension in ['.markdown', '.erb'] + template_name.delete_suffix!(extension) + end + views_root = settings.views || "./views" # Search for any file with the given name and any extension @@ -29,15 +33,7 @@ class TonTonWeb::App < Sinatra::Base file_path = "#{base_dir}/#{template_name}" - extension = File.extname(filename).delete('.') - - engine = case extension - when 'md', 'markdown' then :markdown - when 'erb' then :erb - else - # Fallback: try to use the extension name as the method - extension.to_sym - end + engine = File.extname(filename).delete('.').to_sym # Dynamically call the correct Sinatra method (e.g., erb :hello, markdown :hello) # We use 'send' to call the method by its name symbol