如何在RoR中使用HAML t()帮助器 [英] How to use the HAML t() helper in RoR
本文介绍了如何在RoR中使用HAML t()帮助器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Rails 4开发应用程序,并且希望将辅助t()与HAML一起使用,但是我不能
I'm developing an application with Rails 4 and I want to use the helper t() with HAML, but I can not
示例用法:
=model_name = @article.class.model_name.human
%h1 Create t(:model_name)
我的第一行显示了正确的文章,但是当我使用t()时,它显示了t(:model_name).谢谢.
My first line shows me the correct article, but when I use t() it shows me t(:model_name). Thanks.
推荐答案
希望在翻译文件中具有en.yml
hope in translational file you have en.yml
en:
article: MyArticle
然后
%h2= t 'article'
如果要动态``
%h2= t '#{model_name}'
这篇关于如何在RoR中使用HAML t()帮助器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文