From: Lunar Date: Mon, 3 Jun 2013 10:01:55 +0000 (+0200) Subject: Manually select YAML content in member pages X-Git-Url: https://nos-oignons.net/gitweb/gestion-adh.git/commitdiff_plain/e52ee556380e7ecb6a7a674743ebe6c0cfd561aa?ds=sidebyside Manually select YAML content in member pages This works around a strang bug in the safe_yaml gem. --- diff --git a/features/support/fixtures.rb b/features/support/fixtures.rb index fb06a0c..8280d79 100644 --- a/features/support/fixtures.rb +++ b/features/support/fixtures.rb @@ -62,6 +62,7 @@ email: <%= email %> joined_on: <%= joined_on %> membership_fee_paid_on: <%= membership_fee_paid_on %> --- +[[!ftemplate id="membre"]] <%= notes %> END_OF_TEMPLATE diff --git a/lib/nos_oignons/member.rb b/lib/nos_oignons/member.rb index 8b0bd97..a67581c 100644 --- a/lib/nos_oignons/member.rb +++ b/lib/nos_oignons/member.rb @@ -59,7 +59,8 @@ module NosOignons unless page_content.start_with?("---\n") raise ArgumentError.new('content is not a proper YAML document') end - data = YAML.load(page_content) + yaml_content = /\A---\n(.*)\n---\n/m.match(page_content)[1] + data = YAML.load(yaml_content) MEMBER_FIELDS.each do |field| self[field] = data[field.to_s] end