0

When I have this code in an *.adoc file in awestruct:

This website was generated on {localdatetime}.

I get:

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

But I want it nicely formatted like this:

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

I tried these, but they don't work:

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

which is strange, because calling Ruby methods with #{rubyVariable.someMethod()} in adoc files does work.

Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120
  • It seems that Asciidoctor can not handle date format: http://discuss.asciidoctor.org/Is-there-a-way-to-set-the-date-format-used-td2735.html – Jmini Dec 02 '15 at 20:24
  • Pure Assciidoctor can't, but pure Asciidoctor can't do `#{rubyVariable.someMethod()}` either, so I am hoping Awestruct somehow allows it in an adoc file. It works in a haml file. – Geoffrey De Smet Dec 03 '15 at 07:26
  • 1
    What is the type of `localdatetime`? The interpolation is being done with the awestruct page as the context so if it isn't a variable on the page you won't be able to do anything with it. You could try #{localdatetime.class}, that may give you some ideas. What you may be able to do is to add a helper to do the conversion. – LightGuard Dec 03 '15 at 21:25
  • It just prints `{localdatetime.class}`. I don't think it's a ruby value, as it starts with `{`, not `#{`. I think it's an asciidoc value. – Geoffrey De Smet Dec 04 '15 at 11:24

1 Answers1

1

Add :page-interpolate: true on the top of the *.adoc file

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

Then this works:

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

Output:

 This website was generated on Fri 4 December 2015 at 12:31:09 CET.
Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120