Snippets vs Variables - Best Practices?
Snippets vs Variables - Best Practices?
I know there have been a handful of discussions about snippets vs variables here in the forum in the past, but I am still trying to discover a good basis for deciding one or the other. Does anyone out there have a decision process for choosing to snippetize or variable-ify some piece of content or another?
Re: Snippets vs Variables - Best Practices?
Use a variable when you are specifying a short bit of unformatted text such as the name of a product, product feature, or company.
Use a variable when you are specifying text that might get included within a TOC entry, the destination of a link, or any similar place other than displayed topic text.
Use a snippet when the included content contains formatting or tags of any sort, including anything that is long enough that it needs to exist as its own paragraph, or multiple paragraphs.
Use a variable when you are specifying text that might get included within a TOC entry, the destination of a link, or any similar place other than displayed topic text.
Use a snippet when the included content contains formatting or tags of any sort, including anything that is long enough that it needs to exist as its own paragraph, or multiple paragraphs.
Re: Snippets vs Variables - Best Practices?
So would you use variables, for example, for URLs?
-
- Senior Propellus Maximus
- Posts: 3669
- Joined: Thu Feb 02, 2006 9:57 am
- Location: Pittsford, NY
Re: Snippets vs Variables - Best Practices?
I regularly put URLs and email links in individual snippets. If I were to make them variables, they wouldn't have any "links" behind them.CoolLime wrote:So would you use variables, for example, for URLs?
Nita
RETIRED, but still fond of all the Flare friends I've made. See you around now and then!
RETIRED, but still fond of all the Flare friends I've made. See you around now and then!
Re: Snippets vs Variables - Best Practices?
That's strange, because somehow I have URLs as variables and they do have links... I don't know how that is possible thenNita Beck wrote:I regularly put URLs and email links in individual snippets. If I were to make them variables, they wouldn't have any "links" behind them.CoolLime wrote:So would you use variables, for example, for URLs?
Re: Snippets vs Variables - Best Practices?
I think MadCap has the MadCap:variable.URL style and when I make a URL into a variable, when I insert that variable it automatically uses that style. Or do I have this wrong?Nita Beck wrote:I regularly put URLs and email links in individual snippets. If I were to make them variables, they wouldn't have any "links" behind them.CoolLime wrote:So would you use variables, for example, for URLs?
-
- Senior Propellus Maximus
- Posts: 3669
- Joined: Thu Feb 02, 2006 9:57 am
- Location: Pittsford, NY
Re: Snippets vs Variables - Best Practices?
Couldn't say. I've been using Flare since version 1 so maybe what you write about was some new feature somewhere along the way that I didn't pay attention to as I continued to follow my usual practice. I'll have to go check it out.CoolLime wrote:I think MadCap has the MadCap:variable.URL style and when I make a URL into a variable, when I insert that variable it automatically uses that style. Or do I have this wrong?
FWIW, I'm not talking about styling. I'm talking about the underlying links, plus by putting URLs in snippets, I get to set things such as the target window and other things related to the link themselves.
Nita
RETIRED, but still fond of all the Flare friends I've made. See you around now and then!
RETIRED, but still fond of all the Flare friends I've made. See you around now and then!
Re: Snippets vs Variables - Best Practices?
Well, in a PDF output these links work--so I guess they must be there. That said, are there are any other reasons to use a snippet over a variable for this purpose?Nita Beck wrote:Couldn't say. I've been using Flare since version 1 so maybe what you write about was some new feature somewhere along the way that I didn't pay attention to as I continued to follow my usual practice. I'll have to go check it out.CoolLime wrote:I think MadCap has the MadCap:variable.URL style and when I make a URL into a variable, when I insert that variable it automatically uses that style. Or do I have this wrong?
FWIW, I'm not talking about styling. I'm talking about the underlying link, plus by putting URLs in snippets, I get to set things such as the target window and other things related to the link themselves.
Re: Snippets vs Variables - Best Practices?
The variable is not a hyperlink.CoolLime wrote:Well, in a PDF output these links work--so I guess they must be there.
The link works in a PDF because that's a feature of Adobe Reader - it detects URLs in plain text, and converts them to hyperlinks.
In Adobe Reader, select Edit > Preferences, select General, then deselect Create links from URLs.
Now your links will be plain text, and won't work - so the links are not in the PDF itself.
You can test the "create links" setting by just typing a URL in plain text in your Flare topic, then viewing the PDF. It doesn't have to be in a variable.
Re: Snippets vs Variables - Best Practices?
What I am talking about is when you have a link that needs to have a different destination in different targets. The code for the link includes the variable as the destination for the link. The variable contains the URL. This avoids making multiple versions of the link or the content containing the link side-by-side.Nita Beck wrote:I regularly put URLs and email links in individual snippets. If I were to make them variables, they wouldn't have any "links" behind them.CoolLime wrote:So would you use variables, for example, for URLs?
Re: Snippets vs Variables - Best Practices?
You could use a variable as a link if desired:
Code: Select all
<a href="[%=Variables.URL%]">[%=Variables.URL_Display_Text%]</a>
Re: Snippets vs Variables - Best Practices?
I learned something here. But then what is MadCap|variable.URL then?Dave Lee wrote:The variable is not a hyperlink.CoolLime wrote:Well, in a PDF output these links work--so I guess they must be there.
The link works in a PDF because that's a feature of Adobe Reader - it detects URLs in plain text, and converts them to hyperlinks.
In Adobe Reader, select Edit > Preferences, select General, then deselect Create links from URLs.
Now your links will be plain text, and won't work - so the links are not in the PDF itself.
You can test the "create links" setting by just typing a URL in plain text in your Flare topic, then viewing the PDF. It doesn't have to be in a variable.
Re: Snippets vs Variables - Best Practices?
That's just a custom class called "URL" for variables. Presumably it's just used to style plain text variables as a clickable URL would be.CoolLime wrote:I learned something here. But then what is MadCap|variable.URL then?
Re: Snippets vs Variables - Best Practices?
Understood.AlexFox wrote:That's just a custom class called "URL" for variables. Presumably it's just used to style plain text variables as a clickable URL would be.