-1

このような erb テンプレートがあり、ハッシュ オブジェクトを直接そこにダンプしたいと考えています。

# test.yml.erb
---
name: <%= name || "bat" %>
director_uuid: <%= uuid %>

release:
  name: bat
  version: <%= release.name || "latest" %>

<%= YAML.dump(compilation) %>

update:
  canaries: 1
  canary_watch_time: 3000-90000

<%= YAML.dump(network)%>

しかし、私はERB.new(test.yml.erb).result(binding)これを取得するだけです: # test.yml --- name: bat director_uuid: uuid

release:
  name: bat
  version: lastest

---
compliaton:
  workers: 1
  network: default    

update:
  canaries: 1
  canary_watch_time: 3000-90000

---
networks:
  name: default

不要なものを削除する方法はあり---ますか? どんな助けでもいただければ幸いです

4

1 に答える 1

2

YAML のダンプ出力からそれを削除するだけです。

<%= YAML.dump(compilation).sub(/.*?\n/, '') %>
于 2013-03-28T08:36:44.900 に答える