Skip to content

Commit

Permalink
Fix crash when loading unsupported Tilt handlers
Browse files Browse the repository at this point in the history
Tilt supports lots of different templating engines, each via a different
class.

When Tilt deprecates and removes a templating engine (as recently
happened with Maruku), Ruby will raise a `NameError` exception when we
call `Tilt.const_get` to access the (now missing) class by name.

This patch ignores those errors, allowing Nesta to try loading another
Markdown engine.
  • Loading branch information
gma committed Jan 23, 2025
1 parent b808d0e commit 43e86f8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@

(Suggested by Brad Weslake)

* Handle errors raised when loading missing templating engine.

When a templating engine is removed from the Tilt library (as recently
happened with Maruku), Ruby was raising a `NameError` exception when Nesta
attempted to load it. Nesta now ignores those errors, and tries to load
another Markdown processor.

(Graham Ashton, reported by Curtis Cooley)

* Fix whitespace in version.rb when generating new plugins. (Graham Ashton)

## 0.18.0 (19 November 2024)
Expand Down
2 changes: 1 addition & 1 deletion lib/nesta/models/file_model.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
def register_template_handler(class_name, *extensions)
Tilt.register Tilt.const_get(class_name), *extensions
rescue LoadError
rescue LoadError, NameError
# Only one of the Markdown processors needs to be available, so we can
# safely ignore these load errors.
end
Expand Down

0 comments on commit 43e86f8

Please sign in to comment.