Let's look at a very common example of JSP functionality being used inside CSS. I'm pulling this from the blogs portlet. To be specific, this is from lines
35-44 of
\webapps\ROOT\html\portlet\blogs\css\main.jsp.
1.portlet-blogs .entry-author {
2 background: url(<%= themeImagesPath %>/portlet/edit_guest.png) no-repeat 0 50%;
3 border-right: 1px solid #999;
4 color: #999;
5 float: left;
6 font-weight: bold;
7 margin-right: 10px;
8 padding-left: 25px;
9 padding-right: 10px;
10}
In this example,
<%= themeImagesPath %> is being used to reference the current theme path, which could be
/cool-theme, or
/awesome-theme, or (if you so chose)
/plugins/awesome-theme. There is no way for the CSS to what the path to
/portlet/edit_guest.png really is. Therefore, JSP functionality is (unfortunately) required.
I'm brainstorming now, and I'm not sure if anyone will even read this, but...
I would prefer it if all portlets bundled their own resources so that the assets could be referenced relatively, like
background: url(../images/edit_guest.png), or, in instances where assets are shared between portlets, like
background: url(../../shared-assets/images/edit_guest.png). It should be noted that "shared-assets" is an imaginary name I am giving this directory (and without much thought, so that I may reply quickly to your post).
What do you think?
Please sign in to flag this as inappropriate.