I'm at the start of developing a Rails engine (and gem) that should provide many small helper functions that generate HTML for views.
我正在开发一个Rails引擎(和gem),它应该提供许多小的助手函数来为视图生成HTML。
Now I wonder whether it's advisable to rely on the use of many nested content_tag
calls to generate the HTML, or if it's more pragmatic to just rely on partials.
现在,我想知道是否应该依赖于使用许多嵌套的content_tag调用来生成HTML,或者仅仅依赖部分是否更实用。
In my opinion, the first approach may be a bit cleaner (but slower in performance), but the 2nd approach seems much easier to do, so I guess I will favor the 2nd one. What do you guys think?
在我看来,第一种方法可能更简洁(但是性能更慢),但是第二种方法似乎更容易实现,所以我想我更喜欢第二种方法。你们怎么看?
1 个解决方案
#1
3
many nested
content_tag
calls许多content_tag嵌套调用
does not sound as if you should be doing this in a helper. 1 or 2 levels of tags is my personal limit, above that I go for the partial.
听起来不像是你应该在帮助别人的时候这么做。1或2级标签是我的个人限制,超过了我选择的部分。
Thats just my feeling, no theory involved here :-)
这只是我的感觉,没有理论依据。
#1
3
many nested
content_tag
calls许多content_tag嵌套调用
does not sound as if you should be doing this in a helper. 1 or 2 levels of tags is my personal limit, above that I go for the partial.
听起来不像是你应该在帮助别人的时候这么做。1或2级标签是我的个人限制,超过了我选择的部分。
Thats just my feeling, no theory involved here :-)
这只是我的感觉,没有理论依据。