1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00

treat inline templates as any other element

This commit is contained in:
Gabriel Andretta 2011-06-17 22:43:08 -03:00
parent 41498c52ab
commit 580ecfeff7

View file

@ -48,13 +48,6 @@ module Sinatra
watcher_for(path).elements << element watcher_for(path).elements << element
end end
# Lets the +Watcher+ for the file located at +path+ know that
# it contains inline templates, and adds the +Watcher+ to the
# +List+, if it isn't already there.
def watch_inline_templates(path)
watcher_for(path).inline_templates
end
# Tells the +Watcher+ for the file located at +path+ to ignore # Tells the +Watcher+ for the file located at +path+ to ignore
# the file changes, and adds the +Watcher+ to the +List+, if # the file changes, and adds the +Watcher+ to the +List+, if
# it isn't already there. # it isn't already there.
@ -101,15 +94,10 @@ module Sinatra
@mtime = File.mtime(path) @mtime = File.mtime(path)
end end
# Informs that the file being watched has inline templates.
def inline_templates
@inline_templates = true
end
# Indicates whether or not the file being watched has inline # Indicates whether or not the file being watched has inline
# templates. # templates.
def inline_templates? def inline_templates?
!!@inline_templates elements.any? { |element| element.type == :inline_templates }
end end
# Informs that the modifications to the file being watched # Informs that the modifications to the file being watched
@ -293,13 +281,9 @@ module Sinatra
# extension in its +registered+ method with every reload. # extension in its +registered+ method with every reload.
def watch_element(path, type, representation=nil) def watch_element(path, type, representation=nil)
list = Watcher::List.for(self) list = Watcher::List.for(self)
if type == :inline_templates element = Watcher::Element.new(type, representation)
list.watch_inline_templates(path) list.watch(path, element)
else list.watch(register_path, element) if registering_extension?
element = Watcher::Element.new(type, representation)
list.watch(path, element)
list.watch(register_path, element) if registering_extension?
end
end end
end end
end end