1

I'm using Jekyll with the Jekyll-RDF extension to render some pages for RDF resources. I know how to access the properties of the currently rendered resource in a template. But now I want to access a property of a resource which is linked to the currently rendered resource. So to say I want to make a double hop. But how does that work?

Here is my MWE

The graph:

@prefix ex: <http://example.org/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .

ex:nabatz a foaf:Person ;
          foaf:nick "Nabatz" ;
          foaf:currentProject ex:project .
ex:project a foaf:Project ;
           foaf:name "A Project" .

The template:

---
---
<html>
 <body>
  <h1>{{page.rdf | rdf_property: "<http://xmlns.com/foaf/0.1/nick>"}}</h1>
  <dl>
   <dt>Current Project</dt>
   <dd>{{page.rdf | rdf_property: "<http://xmlns.com/foaf/0.1/currentProject>"}}</dd>
  </dl>
 </body>
</html>

The output:

<html>
 <body>
  <h1>Nabatz</h1>
  <dl>
   <dt>Current Project</dt>
   <dd>http://example.org/project</dd>
  </dl>
 </body>
</html>

What I want:

<html>
 <body>
  <h1>Nabatz</h1>
  <dl>
   <dt>Current Project</dt>
   <dd>A Project</dd>
  </dl>
 </body>
</html>
nabatz
  • 13
  • 2

1 Answers1

0

There are two options to achieve this, depending on what else you want to do with the linked resource.

Option 1

Just chain the rdf_property filter:

{{page.rdf | rdf_property: "<http://xmlns.com/foaf/0.1/currentProject>" | rdf_property: "<http://xmlns.com/foaf/0.1/name>"}}

Option 2

Assign a variable with the linked resource node:

{% assign node = pade.rdf | rdf_property: "<http://xmlns.com/foaf/0.1/currentProject>" %}
{{ node | rdf_property: "<http://xmlns.com/foaf/0.1/name>" }}

If you want to output multiple properties of the linked resource it is better to use Option 2, while Option 1 is more compact.

white_gecko
  • 4,808
  • 4
  • 55
  • 76