Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Look for blocks properties/content #1

Open
alxlg opened this issue Nov 5, 2022 · 1 comment
Open

Look for blocks properties/content #1

alxlg opened this issue Nov 5, 2022 · 1 comment

Comments

@alxlg
Copy link

alxlg commented Nov 5, 2022

I think it could be useful to look for properties and content of blocks too.

In particular I'm referring to:

  1. the parent block if any (maybe fallback to current page title and properties otherwise?)
  2. Previous/next sibling block

An use case for 1. could be:

You are in a page/block about an Author and you want to use a "New Book" template to create a Book that has page title/block content as the value of author:: property:

- Name Surname
  - Title of the book created with a template
    author:: Name Surname
@stdword
Copy link
Contributor

stdword commented Apr 13, 2023

Hi, @alxlg! I know, you are aware of 🏛 Full House Templates plugin. Just left here an instruction on how to achieve some of the described parts for others who come here.

  1. There are context info about block you are rendered template in:

    • the block itself: c.block
    • the page of the block: c.block.page
    • parent block: c.block.parentBlock (supported at a minimal level: only id field)
    • prev sibling block: c.block.prevBlock (supported at a minimal level: only id field)
    • next sibling block is not supported now
    • children blocks: c.block.children — is not supported now

    all unsupported now (for plugin version 2.5.0) could be supported in the future — it is rare case now, but there is an issue to subscribe to: [Context] Blocks Navigation — Get next / prev siblings, parent blocks & children stdword/logseq13-full-house-plugin#12

  2. Case with book and author's page

    • Create template:
      - ``{ c.args.title || 'Title of the book created with a template' }``
        template:: new book
        template-including-parent:: yes
        author:: ``{ ref(empty(c.args.author, c.page.name)) }``
      
    • Render it in [[Name Surname]] page in one of following ways:
      {{renderer :template, new book}}
      {{renderer :template, new book, :title "Book Title"}}
      {{renderer :template, new book, :author Some Author}}
      

Demo

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants