-
Notifications
You must be signed in to change notification settings - Fork 10
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
Passing HTML data attributes #207
Comments
Sometimes posting on the interwebs helps work through the problem. This appears to work in a variety of situations. Feedback appreciated, especially from @jason-fox and/or @infotexture.
If this is a good approach, could it be easily extended to additional Bootstrap components or features not yet part of this family of plugins? My quibble is now the JSON in the HTML is rendered with
|
Just use <xsl:template match="*[@otherprops][data]" mode="commonattributes">
<xsl:variable name="attributeName" select="@otherprops"/>
<xsl:attribute name="{$attributeName}">
<xsl:value-of select="data" disable-output-escaping="yes" />
</xsl:attribute>
</xsl:template> If you are worrying specifically about |
In your case I would probably just create a specialism of the <ph>
<data name="data-anime" props="data-attribute">
{ "el": "childs", "translateY": [30, 0], "opacity": [0,1], "duration": 600,
"delay": 0, "staggervalue":200, "easing": "easeOutQuad" }
</data>
Text goes here....
</ph> Something like this: <xsl:template match="*[contains(@class, ' topic/data ') and contains(@props, 'data-attribute')]">
<xsl:attribute name="@name">
<xsl:value-of select="." disable-output-escaping="yes" />
</xsl:attribute>
</xsl:template> |
I tend to use <section outputclass="parallax py-6 px-4 text-white">
<data name="data-img-src" props="data-attribute">...</data>
<data name="data-speed" props="data-attribute">0.3</data>
Text goes here ...
</section> I think combining all the data-attributes in one place is shorter and easier to read: <section outputclass="parallax py-6 px-4 text-white" otherprops="data-img-src(...) data-speed(0.3)">
Text goes here ...
</section> I suppose it would be possible to amend existing templates to cover something like this. |
Looking for some guidance about best practices.
Within the context of this plugin or any of its related plugins, is there a general mechanism to pass
data-attributes
, perhaps through@otherprops
, similar to what is done with parallax or from thedita-bootstrap.extension
plugin?This is the target HTML we're attempting to get:
and
Notice that the
@data-*
values are JSON, which is not possible to put into@otherprops
. Instead of@otherprops
, what if<data>
was used?Aside:
@otherprops
is not allowed on<title>
.The text was updated successfully, but these errors were encountered: