You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Carsten Ziegeler <cz...@apache.org> on 2017/09/30 10:03:05 UTC

[Site] Placeholders?

Hi,

with the migration of the website, I'm wondering if we can have
placeholders in pages?

For example, the version number of the latest Launchpad release, the
minimun java version to use, the minimum Maven version for building etc.
These things are spread across so many pages and many of them are
outdated - so having placeholders and simply changing them in one place
could make this easier.

Regards
Carsten
-- 
Carsten Ziegeler
Adobe Research Switzerland
cziegeler@apache.org

Re: [Site] Placeholders?

Posted by Carsten Ziegeler <cz...@apache.org>.
Thanks Bertrand,

I've added some variables for min java, min maven and Sling release version.

Regards

Carsten


Bertrand Delacretaz wrote
>> On Mon, Oct 2, 2017 at 5:10 PM, Robert Munteanu <ro...@apache.org> wrote:
>>> ...By reading the discussion at [1] it seems that we have to implement
>>> this ourselves in our templates - there is no placeholder support for
>>> articles...
> 
> I have implemented a basic version of this and used it as an example
> in index.md :
> https://github.com/apache/sling-site/commit/dbae75cbed98d63b15c0499eeb09c6e5eb47a900
> 
> (Groovy regexp replacement with closure FTW ;-)
> (and I fixed the bogus content.expandVariables test later)
> 
> Note the expandVariables=true front matter variable, if that's not set
> there's no replacement, so there's no risk of conflicts with existing
> content.
> 
> The values come from the pageVariables map in page.tpl - in my simple
> example config.blog_subtitle comes from jbake.properties, we can add
> variables there as needed, preferably with a sling. prefix like
> "sling.foo" which becomes sling_foo in the Groovy code.
> 
> Missing variables generate a MISSING_PAGE_VARIABLE marker in the output.
> 
> -Bertrand
> 
-- 
Carsten Ziegeler
Adobe Research Switzerland
cziegeler@apache.org

Re: [Site] Placeholders?

Posted by Bertrand Delacretaz <bd...@apache.org>.
> On Mon, Oct 2, 2017 at 5:10 PM, Robert Munteanu <ro...@apache.org> wrote:
>> ...By reading the discussion at [1] it seems that we have to implement
>> this ourselves in our templates - there is no placeholder support for
>> articles...

I have implemented a basic version of this and used it as an example
in index.md :
https://github.com/apache/sling-site/commit/dbae75cbed98d63b15c0499eeb09c6e5eb47a900

(Groovy regexp replacement with closure FTW ;-)
(and I fixed the bogus content.expandVariables test later)

Note the expandVariables=true front matter variable, if that's not set
there's no replacement, so there's no risk of conflicts with existing
content.

The values come from the pageVariables map in page.tpl - in my simple
example config.blog_subtitle comes from jbake.properties, we can add
variables there as needed, preferably with a sling. prefix like
"sling.foo" which becomes sling_foo in the Groovy code.

Missing variables generate a MISSING_PAGE_VARIABLE marker in the output.

-Bertrand

Re: [Site] Placeholders?

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Mon, Oct 2, 2017 at 5:10 PM, Robert Munteanu <ro...@apache.org> wrote:
> ...By reading the discussion at [1] it seems that we have to implement
> this ourselves in our templates - there is no placeholder support for
> articles...

Note that there's already a processContent method in the page template [0],
we could enhance that to call a suitable variable replacement method.

This can be enabled on a page basis by passing the "content" object to that
method and adding a front matter variable that enables this replacement -
to avoid conflicts with existing content.

-Bertrand

[0]
https://github.com/apache/sling-site/blob/master/src/main/jbake/templates/page.tpl

> [1]: https://groups.google.com/forum/#!topic/jbake-user/-vioxApSJ5A

Re: [Site] Placeholders?

Posted by Justin Edelson <ju...@justinedelson.com>.
Per https://github.com/jbake-org/jbake/issues/326, it looks like we may be
able to do this when Pegdown is replaced.

On Mon, Oct 2, 2017 at 11:10 AM Robert Munteanu <ro...@apache.org> wrote:

> On Sat, 2017-09-30 at 12:03 +0200, Carsten Ziegeler wrote:
> > Hi,
> >
> > with the migration of the website, I'm wondering if we can have
> > placeholders in pages?
> >
> > For example, the version number of the latest Launchpad release, the
> > minimun java version to use, the minimum Maven version for building
> > etc.
> > These things are spread across so many pages and many of them are
> > outdated - so having placeholders and simply changing them in one
> > place
> > could make this easier.
>
> That's a good idea. I gave this a quick shot but failed to find a
> solution in ~10 minutes.
>
> By reading the discussion at [1] it seems that we have to implement
> this ourselves in our templates - there is no placeholder support for
> articles.
>
> Robert
>
>
> [1]: https://groups.google.com/forum/#!topic/jbake-user/-vioxApSJ5A
>

Re: [Site] Placeholders?

Posted by Robert Munteanu <ro...@apache.org>.
On Sat, 2017-09-30 at 12:03 +0200, Carsten Ziegeler wrote:
> Hi,
> 
> with the migration of the website, I'm wondering if we can have
> placeholders in pages?
> 
> For example, the version number of the latest Launchpad release, the
> minimun java version to use, the minimum Maven version for building
> etc.
> These things are spread across so many pages and many of them are
> outdated - so having placeholders and simply changing them in one
> place
> could make this easier.

That's a good idea. I gave this a quick shot but failed to find a
solution in ~10 minutes.

By reading the discussion at [1] it seems that we have to implement
this ourselves in our templates - there is no placeholder support for
articles.

Robert


[1]: https://groups.google.com/forum/#!topic/jbake-user/-vioxApSJ5A