Skip to content
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

Any way to render but keep the original block contents? #1

Closed
Gitbreast opened this issue Mar 17, 2023 · 17 comments
Closed

Any way to render but keep the original block contents? #1

Gitbreast opened this issue Mar 17, 2023 · 17 comments
Labels
bug Something isn't working released

Comments

@Gitbreast
Copy link

Looking for a quick way to insert a wiki link using the current page name, first I consider logseq-powerblocks-plugin then cannibalox in forum recommend this.Then I experience this powerful plugin, it deal with the variable such as page name perfectly.

But while I use it in page property block, I realize it renders after clearing the original content of the block. That means it can't be use in a block that has any content. I think this would cause a big limit to its powerful feature.

So I think is it any way to add the template content but do not clear or replace the original content, just like logseq-powerblocks-plugin?

Discussion: https://discuss.logseq.com/t/any-way-to-get-variables-value-in-custom-commands/15994/1

@stdword
Copy link
Owner

stdword commented Mar 17, 2023

Hello! Thank you for response and feedback! It is really important to me.

Quick response: It is a bug I'm aware of and will be fixed at the very next version.

@stdword stdword added the bug Something isn't working label Mar 18, 2023
@stdword
Copy link
Owner

stdword commented Mar 20, 2023

@Gitbreast check v1.3.0

@Gitbreast
Copy link
Author

@stdword It seems not work. Honestly, even worse for me🤣

OS: MacOS Lastest
Logseq version: 0.8.18
Plugin version: 1.3.0

My template:
截屏2023-03-21 00 37 47
My command:
截屏2023-03-21 00 34 13
Normally, it still always clears the block content then render:
屏幕录制2023-03-21 00 31 51
Sometimes, such as toggle off then toggle on the plugin, without reload(cmd+R) then use directly, it would provide 2 templates at a time and wiggle the page a bit:
屏幕录制2023-03-21 00 35 43

@stdword
Copy link
Owner

stdword commented Mar 21, 2023

Wow! I need to say sorry for misunderstanding.
I've read your words:

do not clear or replace the original content

And fix another case: clearing block content when inserting renderer command, not a rendering template.

→ reopen for now

@stdword stdword reopened this Mar 21, 2023
github-actions bot pushed a commit that referenced this issue Mar 21, 2023
# [1.4.0](v1.3.0...v1.4.0) (2023-03-21)

### Bug Fixes

* clearing template from system props ([3873243](3873243))
* order of rendered blocks & bubling up wrong sibling ([94fc7a8](94fc7a8)), closes [#1](#1)

### Features

* replace only renderer macro during template rendering ([52b074b](52b074b))
@github-actions
Copy link

🎉 This issue has been resolved in version 1.4.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@stdword
Copy link
Owner

stdword commented Mar 21, 2023

Now it works as you expect:

demo.mp4

⚠️ I'll check your exact case with inserting code inside macro later today.

@Gitbreast
Copy link
Author

@stdword Cool! Thanks for the work! I already tested it, it works well now, also with macros.

Another question: Is it possible or a good idea to hide it in Logseq template menu? A setting to switch, or use different property name like “template+” or something like that, to avoid it showing in sys-template menu?

Because of the variables, these “enhanced templates" almost won’t be used in sys-template menu. With time passed, a predictable situation is, normal templates will mix up with them and hard to be pick out.

@stdword
Copy link
Owner

stdword commented Mar 21, 2023

You prev question:

Sometimes, such as toggle off then toggle on the plugin, without reload(cmd+R) then use directly, it would provide 2 templates at a time and wiggle the page a bit

I guess this is Logseq bug with load/reload mechanics of plugins. I face it every day during development. But my investigation give no results on how to fix / hack / avoid it for now 😢

Is it possible or a good idea to hide it in Logseq template menu? A setting to switch, or use different property name like “template+” or something like that, to avoid it showing in sys-template menu?

Mixing up with native templates very likely, yes. I have several ideas to solve it:

  1. 📅 [future] Support native templates syntax to smoothly render them when need. Thus, you can render all your templates with Full House no matter which type they are. Native template renderer will be left behind.
  2. 📅 [future] Template selectors feature: a way to restrict all your templates list by some rule. This rule could be context oriented: for pages with name starts with specified prefix use only selected templates. Or bind specified shortcut to all templates, related to education and another shortcut to all templates related to work. Or hidden by default templates, etc. This idea needs a research and a lot of product design work. May be you could address some thoughts here.
  3. 📅 [future] Inline templates feature. In your «wiki EN» template example: if Full House template renderer could render template by specifying its body just inside the renderer macro — there is no need to give it a name at all. Thus the won't be mixed with other templates.
  4. ✅ [now] You already don't need to specify a name for you template. Full House could render any block as a template — just use block context menu. The restriction here is that you can't wrap it in command or macro like «wiki EN». Because Logseq resets block uuids on every app restart with one exception: if there is an internal reference to that block — uuid will be preserved.

How do you think will these features help in scenario you've provided?

@Gitbreast
Copy link
Author

Gitbreast commented Mar 22, 2023

@stdword WOW sounds great and exciting.

  1. Does it mean full-house could completely replace native template entrance and use “/template” to call up, if the native templates syntax feature has implemented?
  2. The filter feature sounds powerful. Prefix is for namespace? Related binding is for page or block properties(tags..)? Perhaps can consider a build-in property-value filter, so that can specify in a template’s property — it can be retrieved in which pages with which property and what value. It sounds is the most powerful, wouldn’t it a little complex though?
  3. Easy to understand and use, but not so friendly for each time use?
  4. wow. Heard this I thought I could refer the template uuid in its block as a hidden property, then uuid will be preserved so I could del the template name and use uuid to specify. But practice proved it failed.🤣

@stdword
Copy link
Owner

stdword commented Mar 22, 2023

@Gitbreast I've add your wiki EN case to 🏛 Showcases and release new feature for it: check it out in v1.5.0:

args.mp4

@stdword
Copy link
Owner

stdword commented Mar 22, 2023

Does it mean full-house could completely replace native template entrance and use “/template” to call up, if the native templates syntax feature has implemented?

Sure 😎

The filter feature sounds ... the most powerful, wouldn’t it a little complex though?

Technically — absolutely not complex. The main caveats here is product design of the feature. I guess I'll come to community and users of Full House to get feedback, thoughts, usage cases, problems, etc.

inline templates: Easy to understand and use, but not so friendly for each time use?

They will be very similar to :commands from config.edn. But with full house of rendering abilities 😎

wow. Heard this I thought I could refer the template uuid in its block as a hidden property, then uuid will be preserved so I could del the template name and use uuid to specify. But practice proved it failed.🤣

I'll check this case later 👌

@Gitbreast
Copy link
Author

Gitbreast commented Mar 23, 2023

@stdword The arguments feature is a great idea.
Are all macros "space sensitive"? I found if no space between a comma and an argument, the macro would not be rendered.
And it seems sensitive to the order of arguments. In my test, the first argument seems always be considered as a page name, even if I specified all the arguments using -.
image image

@stdword
Copy link
Owner

stdword commented Mar 23, 2023

Are all macros "space sensitive"? I found if no space between a comma and an argument, the macro would not be rendered.

You've faced with known bug, one more time)
I definitely stands on importance to be space-independent and user friendly as much as possible.
Will fixed it after more important ones. You could watch the issue.

And it seems sensitive to the order of arguments. In my test, the first argument seems always be considered as a page name, even if I specified all the arguments using -.

This is true:

  • the first arg after :template is always the template name
  • the second one is always the page name — it was introduced to easily switch c.page context variable

As of for now page arg should be specified (with «—» to skip or in full page-ref form) every time you want to send an argument to template. But I don't like this behaviour too. I will think on ways to get off the ambiguity.
Also created an issue so you could subscribe to get updates.

PS and again — thank you so much for a feedback 🙏💜

@stdword
Copy link
Owner

stdword commented Apr 1, 2023

@stdword hi, again!

I'll check this case later 👌

I promised to return to this point and now it fixed with the last version of 🏛 Full House Templates: just use copy command from context menu block and block uuid WILL be preserved.

Also note a new big feature — :template-view. With views you can create cool auto-rendering stuff like Daily Journal Templates or Folding page references

@Gitbreast
Copy link
Author

Gitbreast commented Apr 1, 2023

@stdword Take me some time to test it. It works well now. Seems like while copying a block ref, Logseq will give a hidden block property id:: in file.

Take a while to notice that template:: and template-including-parent:: false become useless now, then I deleted all the properties of parent blocks and directly copied the ((uuid)) of template block(used to be child block) to my config.edn. Well done.

@stdword
Copy link
Owner

stdword commented Apr 2, 2023

Seems like while copying a block ref, Logseq will give a hidden block property id:: in file

Yes! And exactly the same 🏛 Full House Templates does with context menu commands Copy as 🏛template and Copy as 🏛view.

copied the ((uuid)) of template block(used to be child block) to my config.edn

Just to clarify your case: Do you copy it to :commands section?

@Gitbreast
Copy link
Author

Gitbreast commented Apr 2, 2023

@stdword Yes. I use it like this.

 ;; Add your own commands to speedup.
 ;; E.g. [["js" "Javascript"]]
 :commands
 [ 
   ["Wiki EN" "{{renderer :template, ((64287991-819d-4893-ae70-07edc3524ac3))}}"]
   ["Wiki EN Embed" "{{renderer :template, ((64287991-cf53-498d-a4cd-e4e7cfa66b72))}}”]
   ["Douban" "{{renderer :template, ((64287991-4619-4821-9360-325a2c9d347d))}}"]
   ["saying" "#saying"] 
 ]

My template blocks, no need to add properties to parent blocks now:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

No branches or pull requests

2 participants