Skip to content

Improve block ref anchor text rendering in templates #14457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
TCOTC opened this issue Mar 27, 2025 · 9 comments
Closed

Improve block ref anchor text rendering in templates #14457

TCOTC opened this issue Mar 27, 2025 · 9 comments
Assignees
Milestone

Comments

@TCOTC
Copy link
Contributor

TCOTC commented Mar 27, 2025

解析模板后如果块引用锚文本为空,则获取对应锚文本或填充块 ID

使用以下模板:

.action{ $blocks := queryBlocks "select * from blocks where id='20250327131517-o3i4l3l'" }
.action{ range $v := $blocks }
- 使用双引号是静态锚文本:((.action{$v.ID} ".action{$v.FContent}"))
- 使用单引号是动态锚文本:((.action{$v.ID} '.action{$v.FContent}'))
- 引号内无文本时块引用消失:((.action{$v.ID} "")) ((.action{$v.ID} ''))
.action{end}

锚文本为空时块引用丢失了:

理想情况下应该获取对应的块内容填入锚文本 #14284 ,但如果不打算实现的话,至少应该跟直接粘贴无锚文本的块引用的效果一致,即锚文本自动填充为块 ID

Image

Image

@88250 88250 self-assigned this Mar 28, 2025
@88250 88250 added this to the 3.1.27 milestone Mar 30, 2025
@88250 88250 changed the title 解析模板后如果块引用锚文本为空,则获取对应锚文本或填充块 ID Improve block ref anchor text rendering in templates Mar 30, 2025
88250 added a commit that referenced this issue Mar 30, 2025

Verified

This commit was signed with the committer’s verified signature.
@88250 88250 closed this as completed Mar 30, 2025
@TCOTC
Copy link
Contributor Author

TCOTC commented Mar 31, 2025

@88250 能不能把 ((.action{$v.ID} "")) 解析为静态锚文本的块引用?

@88250
Copy link
Member

88250 commented Mar 31, 2025 via email

@TCOTC
Copy link
Contributor Author

TCOTC commented Mar 31, 2025

能不能当特性,处理为静态锚文本?会有什么问题吗?

@88250
Copy link
Member

88250 commented Mar 31, 2025 via email

@TCOTC
Copy link
Contributor Author

TCOTC commented Mar 31, 2025

有点问题。如果 ID 对应的块不存在,整个模板都不解析了

Image

@88250
Copy link
Member

88250 commented Mar 31, 2025

需要在模板里面自己判空

@TCOTC
Copy link
Contributor Author

TCOTC commented Mar 31, 2025

但是复制 ((20250331174505-1234567 '')) 也是可以直接粘贴生成块引用的,模板也应该一样

@88250
Copy link
Member

88250 commented Mar 31, 2025

不一样的,((id)) 语法直接输入可以形成块引元素,但是 queryBlocks/getBlock 返回空的话要自己处理的,是否形成块引元素可以在模板逻辑中实现。

@TCOTC
Copy link
Contributor Author

TCOTC commented Mar 31, 2025

哦我搞错了,返回空的时候 range $v := $blocks 是没有东西的,这个时候模板没内容是正常的

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

No branches or pull requests

2 participants