在 HTML 中嵌入 Ruby 代码? [英] Embedding Ruby code in HTML?

查看:45
本文介绍了在 HTML 中嵌入 Ruby 代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 PHP 中,可以这样做:

In PHP, it is possible to do this:

<input type="text" value=" <?php echo "Hello world"; ?> ">

是否可以像使用或不使用 Rails 那样将 Ruby 嵌入 HTML 中?

Is it possible to embed Ruby in HTML like that with or without Rails?

推荐答案

您将需要使用像 Ruby 模板 (ERB) 这样的模板引擎.这是一个示例.Rails 使用 ERB,因此您可以轻松地在每个模板中执行此操作.

You will need to use a templating engine like Ruby Templates (ERB). Here's an example. Rails uses ERB so you could easily do this in each of your templates.

这篇关于在 HTML 中嵌入 Ruby 代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆