Hiccdown Development Notes
See full discussionLog in or sign up to participate in this discussion.
With an account, you can revise, criticize, and comment on ideas.Hiccdown methods should live in their own, separate modules. How about they are called ‘renderers’?
module ProductsRenderer
def self.index vc, # …
vc.some_helper_method
end
end
Then how would you call this from a helper method?
I don’t think that’s something people would do a lot, but they still easily could: ProductsRenderer.index(self)
Then how would you call index
from a helper method?
I don’t think that’s something people would do a lot, but they still easily could: ProductsRenderer.index(self)
Hiccdown methods should live in their own, separate modules. How about they are called ‘renderers’?
module ProductsRenderer
def self.index vc, # …
vc.some_helper_method
end
end
A benefit of this approach is that, when people start a new Rails app, they may end up putting whatever they’d otherwise put in a helper in a renderer, since renderers have the benefit of having unambiguously resolvable method names.
Then how would you call this from a helper method?
I don’t think that’s something people would do a lot, but they still easily could: ProductsRenderer.index(self)
Then how would you call index
from a helper method?
I don’t think that’s something people would do a lot, but they still easily could: ProductsRenderer.index(self)
I don’t like the term ‘renderer’ yet. It’s too loaded with meaning, what with Rails already having a render
method in controllers and another render
method in views…
Hiccdown methods should live in their own, separate modules. How about they are called ‘displays’?
module ProductsDisplay
def self.index vc, # …
vc.some_helper_method
end
end
A benefit of this approach is that, when people start a new Rails app, they may end up putting whatever they’d otherwise put in a helper in a display, since displays have the benefit of having unambiguously resolvable method names.
Then how would you call this from a helper method?
I don’t think that’s something people would do a lot, but they still easily could: ProductsRenderer.index(self)
Then how would you call index
from a helper method?
I don’t think that’s something people would do a lot, but they still easily could: ProductsRenderer.index(self)
I’m trying this now. Having to prepend every invocation of a helper method with vc.
is getting really old really fast.
Hiccdown methods should live in their own, separate classes. How about they are called ‘displays’?
class ProductsDisplay
def index vc, # …
vc.some_helper_method
end
end
Behind the scenes, the Hiccdown gem would need to make the instance variables available to the display class:
display = @display_module.new
view_context.instance_variables.each do |iv|
display.instance_variable_set(
iv,
view_context.instance_variable_get(iv)
)
end
Then:
class ProductsDisplay
def index vc, # …
vc.some_helper_method(@products)
end
end
Then how would you call this from a helper method?
I don’t think that’s something people would do a lot, but they still easily could: ProductsRenderer.index(self)
Then how would you call index
from a helper method?
I don’t think that’s something people would do a lot, but they still easily could: ProductsRenderer.index(self)