2015-12-02 73 views
0

當我有這樣的代碼在*.adoc文件awestruct:Awestruct:Time.now.strftime( '%A%-d%B%Y')在asciidoc文件

This website was generated on {localdatetime}. 

我得到:

This website was generated on 2015-11-30 11:01:50 CET. 

但我想它很好地格式化像這樣:

This website was generated on Fri 11 November 2015 11:01:50 CET. 

我嘗試了這些,但他們不工作:

This website was generated on #{Time.now.strftime('%a %-d %B %Y')}. 
This website was generated on #{localdatetime.strftime('%a %-d %B %Y')}. 

這很奇怪,因爲調用adoc文件中的#{rubyVariable.someMethod()}的Ruby方法確實有效。

+0

似乎Asciidoctor不能處理日期格式:http ://discuss.asciidoctor.org/Is-there-a-way-to-set-the-date-format-used-td2735.html – Jmini

+0

Pure Assciidoctor不能,但純粹的Asciidoctor也不能''{rubyVariable.someMethod()}',所以我希望Awestruct以某種方式允許它在adoc文件中。它在一個haml文件中工作。 –

+1

'localdatetime'的類型是什麼?插值是通過awestruct頁面作爲上下文來完成的,所以如果它不是頁面上的變量,那麼您將無法對其執行任何操作。你可以嘗試#{localdatetime.class},這可能會給你一些想法。你可以做的是添加一個助手來完成轉換。 – LightGuard

回答

0

*.adoc文件

= Website info 
:awestruct-description: Website technology and feedback 
:page-interpolate: true 

那麼這個作品的頂部添加:page-interpolate: true

This website was generated on #{Time.now.strftime('%a %-d %B %Y at %H:%M:%S %Z')}. 

輸出:

This website was generated on Fri 4 December 2015 at 12:31:09 CET. 
+0

啊,我假定你已經有頁面插入真實的,否則沒有這個工作。 – LightGuard

相關問題