ruby on rails - XML Tags using Builder -


i building xml export real estate app. using builder gem in rails. , looking way following:

<commercialrent>   "commercialrent figure"   <range>     ...   </range> </commercialrent> 

i can't seem find way implement "text goes here" part

my code:

b.commercialrent(period: "annual", plusoutgoings: self.plus_outgoings) {         self.rent_price;         b.range {            b.min(self.rent_psm_pa_min);            b.max(self.rent_psm_pa_max)       };     }; 

returns:

<commercialrent period="annual" plusoutgoings="no">   <rentpersquaremeter>     <range>       <min>1000</min>       <max>10000</max>     </range>   </rentpersquaremeter> </commercialrent> 

everything prints fine, except self.rent_price missing. can't figure out.

you use text! method produce text node:

- (object) text!(text)

append text output target. escape markup. may used within markup brackets as:

builder.p { |b| b.br; b.text! "hi" }   #=>  <p><br/>hi</p> 

so should trick:

b.commercialrent(period: "annual", plusoutgoings: self.plus_outgoings)   b.text! self.rent_price   #... end 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -