2 ms·
We do something like this -- we call it "partial currying" .. if you think of a partial (in Rails) as a function of a number of parameters, you can render and c
by gfodor 18y ago
We do something like this -- we call it "partial currying" .. if you think of a partial (in Rails) as a function of a number of parameters, you can render and cache the intermediate rendering of a subset of those parameters (curry them.) Subsequent calls can then specify the values for the rest.
The mechanism we use for this is to do some ruby metaprogramming to kludge in some placeholder values for the uncurried values, and then gsub them in in the subsequent passes. (So, the first pass is the only pass that runs the HAML/ERB file, the rest are gsub's) This works for us, since things after the first pass are not changing layout, etc, and need to be high performance. The first pass is a heavyweight rendering at a coarse granularity (and cached), subsequent curries are lightweight gsubs at fine grain.