[nikola-discuss] How to reference a metadata value in reStructuredText?

2020-05-01 Thread Steve
Hi all,

I'm sure I overlooked something basic - how can I output a metadata 
variable from my document via reStructuredText?I've read extensively 
about these values but cannot find how to use one in a post or file.  None 
of the tests below work to render the value assigned to the slug.  Also, 
are there any examples of more advanced .rst documents used with Nikola?  
Maybe I can find some answers by example.


.. title: 1960s Macho Legends
.. slug: macho-legends

My slug is {$slug}

or is it ``slug``

or is it :slug:

our could it be {{% slug %}}

nfw it is {{% raw %}}{{% slug %}}{{% /raw %}}

-- 
You received this message because you are subscribed to the Google Groups 
"nikola-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nikola-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nikola-discuss/5efadc4a-4d7b-4c04-aaa4-dfd677b5b781%40googlegroups.com.


Re: [nikola-discuss] How to reference a metadata value in reStructuredText?

2020-05-02 Thread Steve
Chris, the docs indicate that the value still needs to be resolved to be
passed to the template.

Suppose I create  shortcodes/foo.tmpl as such:

This uses the bar variable: ${bar}

And my post contains this:

{{% foo bar=slug %}}


Then the output file will contain:

This uses the bar variable: slug

But I want to output the value of *slug*.  In shell it would be the simple
difference of echo $slug vs echo slug.














On Fri, May 1, 2020 at 4:13 PM Chris Warrick  wrote:

> On Fri, 1 May 2020 at 22:11, Steve  wrote:
> >
> > Hi all,
> >
> > I'm sure I overlooked something basic - how can I output a metadata
> variable from my document via reStructuredText?I've read extensively
> about these values but cannot find how to use one in a post or file.  None
> of the tests below work to render the value assigned to the slug.  Also,
> are there any examples of more advanced .rst documents used with Nikola?
> Maybe I can find some answers by example.
> >
> >
> > .. title: 1960s Macho Legends
> > .. slug: macho-legends
> >
> > My slug is {$slug}
> >
> > or is it ``slug``
> >
> > or is it :slug:
> >
> > our could it be {{% slug %}}
> >
> > nfw it is {{% raw %}}{{% slug %}}{{% /raw %}}
>
> You could use a template-based shortcode:
> https://getnikola.com/handbook.html#template-based-shortcodes
>
> --
> Chris Warrick <https://chriswarrick.com/>
> PGP: 5EAAEA16
>
> --
> You received this message because you are subscribed to the Google Groups
> "nikola-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to nikola-discuss+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/nikola-discuss/CAMw%2Bj7LWhcs4JrF7Y2tfE94%2B07grZ3hJU9bNaMHFq1fnDm9YkA%40mail.gmail.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"nikola-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nikola-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nikola-discuss/CADP4AcrpfGukVGSeJt%2B3hdLwAcGKu-ZuLctEbu-0SicD1rvY0A%40mail.gmail.com.


Re: [nikola-discuss] How to reference a metadata value in reStructuredText?

2020-05-04 Thread Steve
Chris, thanks for the clue.  I still have not escaped the room.  Tried with 
no avail:

{{% post.title %}}
{{% post.data(title) %}}
{{% post.data title %}}



On Saturday, May 2, 2020 at 11:07:44 AM UTC-4, Chris Warrick wrote:
>
> On Sat, 2 May 2020 at 17:03, Steve > 
> wrote: 
> > 
> > Chris, the docs indicate that the value still needs to be resolved to be 
> passed to the template. 
> > 
> > Suppose I create  shortcodes/foo.tmpl as such: 
> > 
> > This uses the bar variable: ${bar} 
> > 
> > And my post contains this: 
> > 
> > {{% foo bar=slug %}} 
> > 
> > 
> > Then the output file will contain: 
> > 
> > This uses the bar variable: slug 
> > 
> > But I want to output the value of slug.  In shell it would be the simple 
> difference of echo $slug vs echo slug. 
>
> The docs also have this paragraph: 
>
> The post in which the shortcode is being used is available as the post 
> variable, so you can access the title as post.title, and data loaded 
> via the data field in the metadata using post.data(key). 
>
> -- 
> Chris Warrick <https://chriswarrick.com/> 
> PGP: 5EAAEA16 
>

-- 
You received this message because you are subscribed to the Google Groups 
"nikola-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nikola-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nikola-discuss/2fa8dbc2-2475-4cbb-a05d-0cea4b43704c%40googlegroups.com.


Re: [nikola-discuss] How to reference a metadata value in reStructuredText?

2020-05-04 Thread Steve
Why does "title" work but not "slug"?



{{% template %}}

The title is: ${post.slug()}

{{% /template %}}

... rejected

-- 
You received this message because you are subscribed to the Google Groups 
"nikola-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nikola-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nikola-discuss/981fcfd3-f443-4ddc-8690-a2ca95044f5c%40googlegroups.com.


Re: [nikola-discuss] How to reference a metadata value in reStructuredText?

2020-05-04 Thread Steve
What is the context for using* echo '${post.title()}' > shortcodes/foo.tmpl 
*?  This is not restructured text, it would be some sort of shell escape 
that is recognized and executed during a build I suppose?  I could not find 
this documented.  If embedded shell hooks are possible, perhaps I could 
parse the slug value out of the header via awk in order to output it.  
Convoluted but it could work if I can get a reference to the filename being 
processed.


On Monday, May 4, 2020 at 10:03:04 AM UTC-4, Chris Warrick wrote:
>
> On Mon, 4 May 2020 at 16:00, Steve > 
> wrote: 
> > 
> > Chris, thanks for the clue.  I still have not escaped the room.  Tried 
> with no avail: 
> > 
> > {{% post.title %}} 
> > {{% post.data(title) %}} 
> > {{% post.data title %}} 
>
> You need to create templated shortcode, and use `post` inside it: 
>
> echo '${post.title()}' > shortcodes/foo.tmpl 
>
> And then you can use it in a post: 
>
> Post title is: {{% foo %}} 
>
> -- 
> Chris Warrick <https://chriswarrick.com/> 
> PGP: 5EAAEA16 
>

-- 
You received this message because you are subscribed to the Google Groups 
"nikola-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nikola-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nikola-discuss/7aa66290-e349-4452-abf8-798f6bc70a63%40googlegroups.com.