Class: Ovto::Router::HashRouter
- Inherits:
-
Component
- Object
- Component
- Ovto::Router::HashRouter
- Defined in:
- lib/ovto/router/hash_router.rb
Instance Method Summary collapse
Instance Method Details
#render(routes:) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ovto/router/hash_router.rb', line 9 def render(routes:) o 'div' do path = trim_hash(state.ovto_router.path) routes.each do |match_txt, renderer| matcher = Matcher.build(trim_hash(match_txt)) if params = matcher.match?(path) instance_exec(params, &renderer) break end end # A dummy node to bind oncreate hook # NOTE: it needs `key` attribute to ensure calling oncreate event. o 'div', { oncreate: -> { on_create }, style: { display: 'none' }, key: 'Ovto::Router::HashRouter' } end end |