Snippets

Inserting a variable into a snippet

5 months 5 days ago #93972

Jonathan's Avatar Jonathan

Are either of these situations possible?

[%snippet color=[%snippet color-alert%] %]my text message[/%snippet %]

[%snippet %] [%snippet alert-message%] [/%snippet %]

5 months 5 days ago #93973

Peter van Westen's Avatar Peter van Westen Admin

No, you can't nest Snippet tags.

5 months 5 days ago #93974

Jonathan's Avatar Jonathan

Hi Peter. Is there any reason why you wouldn't want to do this or why it would be a bad idea? Because if I could do it it would allow me to keep a really tight consistency on design elements

5 months 5 days ago #93975

Peter van Westen's Avatar Peter van Westen Admin

You can use a combination of Snippets and ReReplacer.
Not sure what you are trying with the closing tags. Snippets doesn't have an opening and closing tag. The tag is replaced with the content of there snippet.
To pass variables to the snippet, see the documentation.

5 months 5 days ago #93976

Jonathan's Avatar Jonathan

Hi Pete.

So I have some code like this
<a class="uk-text-default"><button style="font-size:large;" class="uk-button-primary uk-border-rounded uk-button-large"><i class="fa fa-carrot fa-lg uk-text-default"></i>&nbsp;&nbsp;Request Competitive Marketing Plan</button></a>

I want to standardize on the structure of the button and only replace the icon and text. That way ALL buttons that use this will have a consistent look and feel

5 months 5 days ago #93977

Peter van Westen's Avatar Peter van Westen Admin

5 months 5 days ago #93978

Jonathan's Avatar Jonathan

Yes I get what you are referring to. What I am trying to do is build upon other standardization so that it all cascades. EX:

SNIPPETS - building blocks for consistency and change-once-change-everywhere


copywrite = 2020
peter = Peter Van Westen
jonathan = Jonathan Asbell
address = 123 main street
company = Regular Labs
photo = www.regularlabs.com/images/peter.jpg
footer = [%snippet company %] [%snippet address %]
signature-peter = [%snippet photo%] [%snippet peter%] [%snippet copywrite%] [%snippet company%] [%snippet address%]
signature-jonathan= [%snippet photo%] [%snippet jonathan%] [%snippet copywrite%] [%snippet company%] [%snippet address%]

[%snippet signature-peter%]

[%snippet signature-jonathan%]

5 months 5 days ago #93979

Peter van Westen's Avatar Peter van Westen Admin

Again, that is not possible with Snippets. I recommend you look into ReReplacer. Then you can create replacements as crazy as you want following whatever syntax you want. You just need to know the correct Regular Expressions syntax to create the ReReplacer items.

5 months 5 days ago #93980

Jonathan's Avatar Jonathan

Hi Pete. Yes I understand. What I wanted to know is why you dont feel its a compelling use case enough to allow snippets to do that? Can you imagine how fast and consistent it would be to create and also to make incremental changes to content?

5 months 5 days ago #93981

Peter van Westen's Avatar Peter van Westen Admin

This is outside the scope of Snippets.