Closed morrica closed 1 year ago
Hi @morrica,
It looks like this was intended, but does not appear to be working in some cases.
The source for sitemesh:write
is here
You can see where it should be setting the default contents: https://github.com/sitemesh/sitemesh3/blob/1872f3c4c954257169cff50840fa916b23d14ee0/sitemesh/src/main/java/org/sitemesh/content/tagrules/decorate/SiteMeshWriteRule.java#L67-L69
The correct syntax is <sitemesh:write property="meta.description">My default description</sitemesh:write>
I'll try to put together a demo in the next few days.
@codeconsole I tried that syntax. Didn't work. The default is not used. Could it be an issue with my setup? I am using spring boot 3.1.4 with the following sitemesh dependencies:
<dependency>
<groupId>org.sitemesh</groupId>
<artifactId>spring-boot-starter-sitemesh</artifactId>
<version>3.2.0-M2</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.sitemesh</groupId>
<artifactId>sitemesh</artifactId>
<version>3.2.0-M2</version>
</dependency>
@morrica might be a bug, let me look into it
@morrica so it looks like for SiteMesh 3 it was never designed to work that way. It only showed the default content if blank content was being decorated. I am not quite sure the scenario where one would decorate null content, but that was the design.
I just updated sitemesh:write
to now also display the default content if the property is not found so <sitemesh:write property="meta.description">My default description</sitemesh:write>
should now work and display My default description
if that description meta tag is not on the page.
You can test it out by using the latest SNAPSHOT build.
<repositories>
<repository>
<id>sonatype-snapshots</id>
<name>SonaType Snapshot Repository</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
</repositories>
...
<dependency>
<groupId>org.sitemesh</groupId>
<artifactId>spring-boot-starter-sitemesh</artifactId>
<version>3.2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.sitemesh</groupId>
<artifactId>sitemesh</artifactId>
<version>3.2.0-SNAPSHOT</version>
</dependency>
You can resolve it using the SNAPSHOT repository: https://oss.sonatype.org/content/repositories/snapshots/
or download the latest jar directly from here
Please let me know if that works for you.
@codeconsole Thank you very much!
Older versions of sitemesh supported the ability to provide a "default" for a property if it was not found in the page being decorated. Is this functionality available in sitemesh 3?
Something like
<sitemesh:write property="meta.description" default="My default description"/>
or<sitemesh:write property="meta.description">My default description</sitemesh:write>
Seem like they would make sense but neither work. I am unable to locate the
<sitemesh:write>
code in the source to examine any additional parameters that might be available for setting the default.If this functionality currently exists please let me know. If not, I think it would be a very useful feature to add.