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

Proposition : default block definition & class def in block #122

Open
SylvainGuieu opened this issue Aug 24, 2022 · 5 comments
Open

Proposition : default block definition & class def in block #122

SylvainGuieu opened this issue Aug 24, 2022 · 5 comments

Comments

@SylvainGuieu
Copy link

SylvainGuieu commented Aug 24, 2022

Hello,
Thanks again to this amazing plugin.
I have two propositions :

  1. Define the default of a block somewhere, (probably in front-mater ?).
    If a template block is not set in a slide, but defined in template, the default text is displayed (instead of the <% block_name %>)
    This would allow to automatically fill default information such as author, date, meeting name, add logos, etc without editing the core templates which are focused to layouts the content.

    Maybe something like this in presentation md front-matter:

---
defaults:
     footer: My Name  -  2022-08-24
     topleft: "![[my_logo.png|100]]"
     title: "!!... Title Here ...!!"
---

The block footer, topleft, title would be defined in templates.

  1. Add additional classes directly after the block name. Not sure about the grammar, but for instance :
::: block | fragment tiny with-border
Content
:::

or

::: block[fragment tiny with-border]
Content
:::

Would be equivalent to

::: block
Content
:::<!-- .element class="fragment tiny with-border" -->
@MSzturc
Copy link
Owner

MSzturc commented Aug 24, 2022

The idea of the current solution was to support the user on setting missed placeholders. Im not a fan for configuration in templates. It makes using templates more complicated and more it doesnt support the user of the template on configuration.

I would suggest to use composition to solve your problem (i do it for my templates too). My templates are hierachical. I have a tpl-50-50 template that creates a 50% 50% view with a title and two placeholders left and right and a footer. Most of the time i use a default footer. therefore i've created another template tpl-50-50-default that implements the footer placeholder.

Therefore i always use the default variant of my template and if i need a special footer, i delete the -default suffix and advanced slides will tell me that there are placeholders that have to be filled ;-) I dont need to remember the variable i have to configure or get unfocused because i have to study the template file finding out what i have to configure.

Another benefit of this solution is that you have more control, since you could define defaults on slide based, not as in your solution on deck base

@SylvainGuieu
Copy link
Author

hum. ... Not sure we understand each other.
I am more looking for a solution to not repeat the same thing on each slide, (the date, the name of the event, some logo, ..) without having to re-write all my templates (which are more focus on setting the layout).

Therefore the configuration would not be on the templates but on the markdown slide front matter.

cheers.

@MSzturc
Copy link
Owner

MSzturc commented Aug 24, 2022

I understood your approach and as i wrote it's possible to solve your problem by composition and i would recommended it.
Configurable templates make the process of working with template more error prone and don't have the time to support people that are overwhelmed by the feature set.

@SylvainGuieu
Copy link
Author

SylvainGuieu commented Aug 24, 2022

hi again,
This is more an impressed user feedback and proposition than asking for support.

I really do not think your proposal could work for my need. I do not need global default (like e.g. copyright) but data repeated across slide in the context of one presentation. If i use templated "tpl-*-default" it would mean I need to edit all the used "-default" emplate to change the date for instance.

The workaround I found is to write on top of the md file :

<style>
.lfoot:after {
  content: "Star Formation worckshop - San Francisco 12 Nov 2022 ";
}
.rfoot:after {
  content: "My Name";
}
</style>

Where lfoot and rfoot classes are defined in templates for the <%? lfoot %> and <%? rfoot %> blocks.
It works at least on Safary Chrome and Obsidian (electron).
The drawback is that you cannot replace the content on a specific slide, but this can be done by calling an other template as you mentioned (a template that does not define the lfoot and rfoot classes).

Basically one of my template looks like this:

grid drag="100 10" drop="0 2"   align="topleft" class="title-grid">
 <% title %><!-- .element class="title"-->
</grid>
	<% content %><!-- element class="content" -->

<grid drag="50 5" drop="0 -5" align="bottomleft" class="lfoot-grid">
<%? lfoot %><!-- element class="lfoot" -->
</grid>
<grid drag="50 5" drop="50 -5" align="bottomright" class="rfoot-grid">
<%? rfoot %><!-- element class="rfoot" -->
</grid>

As for the original proposal 2., I though it could facilitate the writing and reading.

Cheers.
S

@agentlibre
Copy link

Could this be part of the properties instead of templates?

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

No branches or pull requests

3 participants