Jump to content

Mysteries of the <span> tag revealed


Dan Korn

Recommended Posts

The <span> tag is a powerful feature of the FusionPro VDP products suite. Unfortunately, it's currently undocumented. This post attempts to remedy that shortcoming.

 

The <span> tag pair was designed to allow style overrides over a specific range, or span, of text. The initial, or opening, <span> tag can take several attributes, which specify style attributes to be overridden in the span. The overrides remain in effect until the ending, or closing, </span> tag is reached.

 

The <span> tag can take any number of the following optional attributes:

 

  • suppress={true|false}. Defaults to false. If true, all text within the span is suppressed.
  • accumulate={true|false}. Defaults to false. If false, the ending </span> tag restores the style in effect at the beginning of the span. If true, the ending </span> tag restores the style, taking into account any other changes within the span.
  • color=(color name). If present, the specified named color is applied to the entire span as an override.
  • shading=(percentage) If present, the specified shading, or tint, percentage is applied to the entire span as an override. All colors applied to text within the span are shaded by the specified percentage.
  • pointsize=(number). If present, the specified point size is applied to the entire span as an override. Units are in points.
  • font=(font name). If present, the specified named font is applied to the entire span as an override.
  • bold={true|false}. If present, the style of the entire span is set to either bold or not bold, as an override.
  • italic={true|false}. If present, the style of the entire span is set to either italic or not italic, as an override.

If the <span> tag is used without any attributes, it effectively acts as way to save the running text style and restore it when the ending </span> tag is reached. For example:

<color name="Black">Hi <span><variable name="NameInColor"></span>, you're a winner!

This ensures that the original running style of the text is restored, no matter what the "NameInColor" rule does, even if it changes the running color of the text using a <color> tag.

Edited by mhilger
Link to comment
Share on other sites

  • 3 months later...

Dan:

 

Thanks for this info. It is very helpful for some things that we are working on right now. I do one follow-up question, though. I don't understand the explanation for the accumulate=true attribute. I'm not sure what you mean by "taking into account any other changes within the span." Can you provide a example to clarify?

 

Thanks,

 

-- andy --

Link to comment
Share on other sites

I don't understand the explanation for the accumulate=true attribute. I'm not sure what you mean by "taking into account any other changes within the span." Can you provide a example to clarify?

This example should illustrate the effect of the "accumulate" attribute:

return "Accumulate off:<t><span color=Red>Hi<color name=Green> there!</span> After span<br>\n" +
   "Accumulate ON:<t><span color=Red accumulate=true>Hi<color name=Green> there!</span> After span";

Link to comment
Share on other sites

  • 3 years later...

Hi,

 

I have a business card which includes name and qualification.

 

If the qualification is not present, just the name will be shown.

The name and qualification need to be indifferent colours.

This appears to be a job for <span>

I have the following:

 

if (Field("Qualification 1").length < 0)

return < color name ="pantone 335 C"><span> Field("First name") +" " +Field("Last name");</span>

else

return <color name = "pantone 335C"> <span> Field("First name") + " " + Field("Last name")</span>+ "\n" <color name = "grey"> <span>+Field("Qualification 1")+" " + Field("Qualification 2")</span>;

 

Which clearly doesn't work.

 

Any pointers would be gratefully accepted.

Link to comment
Share on other sites

Your syntax is a little off. You need quotes around your tags and you're missing a couple of plus signs. And if you want to simplify a few things, you can just use the color tags, you don't need the span tags as well:

 

var result = '<color name ="pantone 335 C">' + Field("First name") + " " + Field("Last name") + '</color>';
result += (Field("Qualification 1") != "") ? '\n <color name = "grey">' + Field("Qualification 1") + " " + Field("Qualification 2") + '</color>' : "";
return result;

Link to comment
Share on other sites

This code yields the correct colours but doesn't insert a line break/feed.

Could there be an issue with the \n?

 

 

var result = '<color name ="pantone 335 C">' + Field("First name") + " " + Field("Last name") + '</color>';

result += (Field("Qualification 1") != "") ? '\n <color name = "pantone 430 C">' + Field("Qualification 1") + " " + Field("Qualification 2") + '</color>' : "";

return result;

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...