Tag: 帮手

如何将类添加到image_tag rails helper

我有以下代码: <%= image_tag iterator.image.url(:small), :class => "img_preview" %> 但是呈现的HTML显示: <img src="/actives/hotels/13/small/clean_wave.jpg?1317675452" alt="Clean_wave"> 为什么“class”属性不在? 谢谢!

Silex&Twig助手在自定义错误页面中

在尝试在Silex呈现自定义错误页面时,我正在努力解决问题。 根据我在这个链接中find的: http : //refactoring.us/silex/custom-error-pages-with-silex-and-twig/ 我试图在我的应用程序中设置一个自定义的404错误页面。 一切工作正常,直到我开始在我的树枝模板中使用助手。 404错误页面模板的示例代码如下所示: {% extends "layout.html.twig" %} {% block main %} <div id="error404"> <h2>{{ app.translator.trans('page404.title') }}</h2> <p>{{ app.translator.trans('page404.para1') }}</p> <p class="btn-footer"> <a href="{{ url('home') }}" class="btn">{{ app.translator.trans('page404.button') }}</a> </p> </div> {% endblock %} 我的Silex应用程序中的error handlingPHP代码: $app->error(function (\Exception $e, $code) use($app) { switch ($code) { case 404: $message = $app['twig']->render('error404.html.twig'); break; […]

helper和helper_method做了什么?

helper_method很简单:它使部分或全部控制器的方法可用于视图。 什么是helper ? 反过来,也就是说,它将辅助方法导入到文件或模块中? (也许名字helper和helper_method是相同的,他们可能会改为share_methods_with_view和share_methods_with_view ) 参考