I'm trying to understand the functional difference between using variables and snippets for small chunks of content. This is kind of a vague question, as I'm just trying to understand the Flare philosophy behind two methods I see to accomplish the same goal.
Let's say I have product whose name I expect to change several times (as marketing is wont to do) so I want to turn all the mentions of the product name into some text that I can update once and have it replaced everywhere in the document.
I can either make a 'productName.flsnp' file and have it contain the text 'Product Name A' or create a 'productName' variable in the variable set and define that variable as 'Product Name A' ... then whenever I want to have the product name appear, I insert either the snippet or the variable. Later, I can update either the text of the snippet text or the variable definition to 'Product Name B' and not have to manually replace every instance of the product name in the doc.
I'm just not sure what the differences are between these two methods. I understand that the information will be in a different place and using a variable won't create another file in Content directory, but other than that, why would I want to use one of these methods over the other? Are inserted variables or snippets styled differently? Is there some other reason to prefer either snippets or variables for this sort of task?
Thank you!
Difference between snippets and variables
Re: Difference between snippets and variables
For the example you wrote, use variables. The recommended method is to put placeholder text in the variable value in the project (e.g., set variable called ProductName to have a value of ReplaceProductName). Then in each target, you modify the value of that variable in the target, not in the project variable set. Whenever you build that target, it grabs the correct value for ProductName from the target file and replaces it with the specified value in the output. If you open the output and see the word ReplaceProductName, then you know that you forgot to change the value of the variable in the target. This is helpful if in a year or two you decide to create a new target; you might forget that you have to change the variable value, so if you see that placeholder text, it's a reminder to correct the value in the target file.
Snippets can contain variables or pretty much any other element. There are numerous reasons to use a snippet. For example, I have a snippet that contains a variable, but I have a span class around the variable, so the variable will appear italicized everywhere that I have the snippet inserted (applying a style class to a variable directly doesn't work, unless that changed in v10).
The main reason to use snippets is for multiple-use content. For example, say you have a note that you want to place in several topics and the note contains the exact same content. You could type the note manually in each topic, or you could put the content into a snippet and then insert the snippets in every topic that should contain the note. The benefits of the snippet, in this case, is that you only go one place if you need to modify the content (as opposed to modifying multiple topics), and you can make the appearance of the note consistent across all those topics. That's an example of a snippet block -- you insert the snippet and do nothing with it.
I also have snippets that contain a specific setup, such as my notes versus warnings versus tips. I insert the note/warning/tip snippet into a topic as a snippet block, then I break the link to the snippet file so that I can edit the content in the topic. In this case, the snippet contains my structure (a div inside a div that has an icon positioned where I want it relative to the text), so I don't have to rebuild that structure every time I want to insert a note/warning/tip.
Those are a few examples of how you can use a snippet. So it's not necessarily an either/or argument between snippets and variables -- it's a matter of the purpose of the content.
Oh, and the fact that variables can only contain a few words, at most, whereas a snippet can contain an entire topic.
Snippets can contain variables or pretty much any other element. There are numerous reasons to use a snippet. For example, I have a snippet that contains a variable, but I have a span class around the variable, so the variable will appear italicized everywhere that I have the snippet inserted (applying a style class to a variable directly doesn't work, unless that changed in v10).
The main reason to use snippets is for multiple-use content. For example, say you have a note that you want to place in several topics and the note contains the exact same content. You could type the note manually in each topic, or you could put the content into a snippet and then insert the snippets in every topic that should contain the note. The benefits of the snippet, in this case, is that you only go one place if you need to modify the content (as opposed to modifying multiple topics), and you can make the appearance of the note consistent across all those topics. That's an example of a snippet block -- you insert the snippet and do nothing with it.
I also have snippets that contain a specific setup, such as my notes versus warnings versus tips. I insert the note/warning/tip snippet into a topic as a snippet block, then I break the link to the snippet file so that I can edit the content in the topic. In this case, the snippet contains my structure (a div inside a div that has an icon positioned where I want it relative to the text), so I don't have to rebuild that structure every time I want to insert a note/warning/tip.
Those are a few examples of how you can use a snippet. So it's not necessarily an either/or argument between snippets and variables -- it's a matter of the purpose of the content.
Oh, and the fact that variables can only contain a few words, at most, whereas a snippet can contain an entire topic.
Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
Re: Difference between snippets and variables
Oh, that's interesting - I think the thing I didn't understand was that user-defined variables were changed at the level of the target, not the project. That actually makes sense! I'll see if I can play around with that, and it sounds like I can do what I want with that.
-
ccardimon
- Propellus Maximus
- Posts: 1571
- Joined: Fri Jan 11, 2008 1:30 pm
- Location: Horsham, Pennsylvania
Re: Difference between snippets and variables
As I see it then, I would set up the variables in Project/Variables, but change the values or definitions of the variables in Project/Targets. Is this correct?LTinker68 wrote:The recommended method is to put placeholder text in the variable value in the project (e.g., set variable called ProductName to have a value of ReplaceProductName). Then in each target, you modify the value of that variable in the target, not in the project variable set. Whenever you build that target, it grabs the correct value for ProductName from the target file and replaces it with the specified value in the output.
Craig
Lost in Disturbia
Lost in Disturbia
-
wclass
- Propellus Maximus
- Posts: 1238
- Joined: Mon Feb 27, 2006 5:56 am
- Location: Melbourne, Australia
Re: Difference between snippets and variables
Yes - that's correct.ccardimon wrote:As I see it then, I would set up the variables in Project/Variables, but change the values or definitions of the variables in Project/Targets. Is this correct?LTinker68 wrote:The recommended method is to put placeholder text in the variable value in the project (e.g., set variable called ProductName to have a value of ReplaceProductName). Then in each target, you modify the value of that variable in the target, not in the project variable set. Whenever you build that target, it grabs the correct value for ProductName from the target file and replaces it with the specified value in the output.
I set up the variables in the Project Organizer and initialise them to either a default value or blank. Then, in each target, I set the variable to what it needs to be for that target output.
Margaret Hassall - Melbourne
-
ccardimon
- Propellus Maximus
- Posts: 1571
- Joined: Fri Jan 11, 2008 1:30 pm
- Location: Horsham, Pennsylvania
Re: Difference between snippets and variables
Thanks, Margaret. BTW, I don't see anything in the Project ribbon that says "Organizer." Am I being too literal?
Craig
Lost in Disturbia
Lost in Disturbia
-
wclass
- Propellus Maximus
- Posts: 1238
- Joined: Mon Feb 27, 2006 5:56 am
- Location: Melbourne, Australia
Re: Difference between snippets and variables
Yep - too literal 
It's not in the ribbon, look at the main navigation bar on the left - there's the Project Organizer with the Content Explorer (unless you've customised your layout).
It's not in the ribbon, look at the main navigation bar on the left - there's the Project Organizer with the Content Explorer (unless you've customised your layout).
Margaret Hassall - Melbourne
-
pawel_kowaluk
- Jr. Propeller Head
- Posts: 1
- Joined: Tue Dec 13, 2016 3:27 am
Re: Difference between snippets and variables
Hey, sorry to be reviving this thread, but I think my question is appropriate here: in the light of all that has been discussed, what's the point of using variables?
The reason I am asking is because variables seem like the same thing as snippets, only handled in a separate way. If you want to create a variable with multiple values and you have to specify in the target which values to use, wouldn't it be better to use snippets and apply conditioning? That way you would not have to set up a separate thing in your target.
I can see variables would be useful if:
a. You do not use conditioning in your project and want different variable values for different targets
b. Use conditioning,m but need a separate layer of variable handling, where for one conditioning scheme each variable can have two or more values
Am I on the right track?
The reason I am asking is because variables seem like the same thing as snippets, only handled in a separate way. If you want to create a variable with multiple values and you have to specify in the target which values to use, wouldn't it be better to use snippets and apply conditioning? That way you would not have to set up a separate thing in your target.
I can see variables would be useful if:
a. You do not use conditioning in your project and want different variable values for different targets
b. Use conditioning,m but need a separate layer of variable handling, where for one conditioning scheme each variable can have two or more values
Am I on the right track?
Re: Difference between snippets and variables
You certainly could do snippets with multiple sets of conditionalized text in each in place of a variable with multiple values, if the snippet is only ever used in the text of a topic. But there are things you can only do with each method.
With variables, you can insert them in TOC entries and other places besides the content of a topic.
With snippets, you can include tags for bold, italic, images, etc. in the text, and (for block snippets only) you can include multiple paragraphs, tables, etc.
With variables, you can insert them in TOC entries and other places besides the content of a topic.
With snippets, you can include tags for bold, italic, images, etc. in the text, and (for block snippets only) you can include multiple paragraphs, tables, etc.