Use all awestruct variables in asciidoc

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Use all awestruct variables in asciidoc

ge0ffrey
I have a yml files in my _config dir with many variables.
  _config/pom.yml
Is there a way to expose all the variables of pom.yml in asciidoc files,
similarly as how they are all available in markdown?



For example, pom.yml contains:
latest:
     version: 6.0.0.CR4
     distributionZip:
http://download.jboss.org/drools/release/6.0.0.CR4/optaplanner-distribution-6.0.0.CR4.zip
     releaseDate: 2013-09-30

So I 'd like to do this in download.adoc:
* {site.pom.latest.distributionZip}[Download OptaPlanner
{site.pom.latest.version}]
** Release date: +{site.pom.latest.releaseDate}+


---------------------------------------------------------------------
Archives: http://talk-archive.awestruct.org/
To unsubscribe, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Use all awestruct variables in asciidoc

LightGuard
Administrator
If you're using 0.5.4.rc1 (please let us know if there are problems), take a look at the tests in https://github.com/awestruct/awestruct/pull/364/files

Basically if you add

[source,asciidoc]
----
= Title
:page-interpolate: true
----

to your asciidoc pages you should be able to access things like #{site.blah} or #{page.blah} (though we really don't recommend adding things to the page outside of the standard asciidoc way(s)).


On Thu, Oct 10, 2013 at 8:21 AM, Geoffrey De Smet <[hidden email]> wrote:
I have a yml files in my _config dir with many variables.
 _config/pom.yml
Is there a way to expose all the variables of pom.yml in asciidoc files,
similarly as how they are all available in markdown?



For example, pom.yml contains:
latest:
    version: 6.0.0.CR4
    distributionZip: http://download.jboss.org/drools/release/6.0.0.CR4/optaplanner-distribution-6.0.0.CR4.zip
    releaseDate: 2013-09-30

So I 'd like to do this in download.adoc:
* {site.pom.latest.distributionZip}[Download OptaPlanner {site.pom.latest.version}]
** Release date: +{site.pom.latest.releaseDate}+


---------------------------------------------------------------------
Archives: http://talk-archive.awestruct.org/
To unsubscribe, e-mail: [hidden email]




--
Reply | Threaded
Open this post in threaded view
|

Re: Use all awestruct variables in asciidoc

ge0ffrey
:page-interpolate: true
doesn't fix it with
gem 'awestruct', '~> 0.5.1'
gem 'asciidoctor', '>= 0.1.4'

I 'll try upgrading to 0.5.4.rc1 in the morning and see if that fixes it.
Reply | Threaded
Open this post in threaded view
|

Re: Use all awestruct variables in asciidoc

LightGuard
Administrator
It isn't going to pick it up because it's not a final gem. You'll have to use the full name in your Gemfile.

Sent from my iPhone

> On Oct 10, 2013, at 14:10, ge0ffrey <[hidden email]> wrote:
>
> :page-interpolate: true
> doesn't fix it with
> gem 'awestruct', '~> 0.5.1'
> gem 'asciidoctor', '>= 0.1.4'
>
> I 'll try upgrading to 0.5.4.rc1 in the morning and see if that fixes it.
>
>
>
> --
> View this message in context: http://talk-archive.awestruct.org/Use-all-awestruct-variables-in-asciidoc-tp339p341.html
> Sent from the Awestruct Talk mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> Archives: http://talk-archive.awestruct.org/
> To unsubscribe, e-mail: [hidden email]
>

---------------------------------------------------------------------
Archives: http://talk-archive.awestruct.org/
To unsubscribe, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Use all awestruct variables in asciidoc

ge0ffrey
0.5.4.rc in combination with the "#{var}" format (instead of "{var}") works like a charm. Thanks! :)

Note: "#{var}" didn't work in earlier versions and I started confusing
- #{} which is awestruct stuff
- with {} which is asciidoc stuff
Reply | Threaded
Open this post in threaded view
|

Re: Use all awestruct variables in asciidoc

mojavelinux
On Fri, Oct 11, 2013 at 1:32 AM, ge0ffrey <[hidden email]> wrote:
0.5.4.rc in combination with the "#{var}" format (instead of "{var}") works
like a charm. Thanks! :)

Excellent.
 

Note: "#{var}" didn't work in earlier versions and I started confusing
- #{} which is awestruct stuff
- with {} which is asciidoc stuff

Indeed, they are very similar. This will be something important to emphasis in the (not yet written) AsciiDoc in Awestruct guide*.

Keep in mind, this is one of those "use sparingly features", hence why it's disabled by default. For the purpose you are using it for, it's the ideal use case for it...the web pages are very specific about the data being fed in and not likely to be reused in other contexts. If these creep into regular docs, then they start to look like a JSP rendered inside an IDE...if you get the drift :) Garbage.

We are still pursuing the idea of dot notation in AsciiDoc attribute references to resolve complex data types. With that feature implemented, we may be able to eliminate the need for page-interpolate in all but the very edge cases. Until then, page-interpolate is it.

-Dan

* There should be a guide on the Awestruct site for each language. In the beginning we could get away with just saying "we support all them languages" but now that Awestruct is being adopted by a broader, and often more general purpose, users, we need to get more specific about the various options an how they work.

--