Content Element Order

1 view
Skip to first unread message

TMFReason

unread,
Jul 6, 2010, 3:53:18 PM7/6/10
to Spark View Engine Dev
I found an older post that explains my problems pretty well and was
wondering if there is a best solution.

======html.spark:=======
<head>
<use:head>
</head>
=============
=======Application.spark:======
<content:head>
LAYOUT
</content>
=============
=======View.spark:======
<content:head>
VIEW
</content>

<use file="menu"/>
=============
=======Menu.spark:======
<content:head>
PARTIAL FROM VIEW
</content>
=============

OUTPUT:
========
VIEW
LAYOUT
PARTIAL FROM VIEW
========

but I expect:

========
LAYOUT
VIEW
PARTIAL FROM VIEW
========

Which would cause issues with dependent css and js included in this
manner. Is there a way control the order with the "add" attribute or
does this only apply to existing variables? Or even if so, is there
an elegant way to do this with variables? Or is the best pattern to
use nested content elements such as:

<content:head>
LAYOUT
<use content="viewhead"/>
</content>
=======View.spark:======
<content:viewhead>
VIEW
</content>

Igor Loginov (aka ilog2000)

unread,
Jul 8, 2010, 5:47:04 PM7/8/10
to Spark View Engine Dev
A little bit strange structure... OK, let's take a look:
- html.spark is a master page (layout) and there is content definition
<use content="head" />
- Application.spark and View.spark are two views, they both have <use
master="html" />. Normally, different views correspond to different
actions and cannot co-exist on the page. You found a way to combine
them in one page, so, from this moment the order of their appearance
strongly depends on which is the first found in file system.
- Menu.spark should be a partial, and you are not allowed to put
<content name="head" /> there.

Does it give you an idea? BTW, do you have spark syntax normally
highlighted (which means no error in spark markup)?

TMFReason

unread,
Jul 9, 2010, 11:23:22 AM7/9/10
to Spark View Engine Dev
Well, the structure I meant was a base master, nested master, and
view. In the case of just including css, I have:

Admin.spark (the base master for all admin tools) which has:
<link rel="stylesheet" type="text/css" href="/css/admin.css"/>
<use content="styles"/>

Tickers.spark (nested master for all ticker admin views) which has:
<use master="Admin"/>
<content name="styles">
<link rel="stylesheet" type="text/css" href="/css/tickers.css"/>
</content>

Plus views that may or may not add some page specific css.
<use master="Tickers"/>
<content name="styles">
<link rel="stylesheet" type="text/css" href="/css/view.css"/>
</content>

I was hoping to get:
<link rel="stylesheet" type="text/css" href="/css/admin.css"/>
<link rel="stylesheet" type="text/css" href="/css/tickers.css"/>
<link rel="stylesheet" type="text/css" href="/css/view.css"/>

But instead get:
<link rel="stylesheet" type="text/css" href="/css/admin.css"/>
<link rel="stylesheet" type="text/css" href="/css/view.css"/>
<link rel="stylesheet" type="text/css" href="/css/tickers.css"/>

Which may cause problems with css rule precedence. I tried using the
add="before|after" attribute without success.

Igor Loginov (aka ilog2000)

unread,
Jul 9, 2010, 11:56:56 AM7/9/10
to Spark View Engine Dev
And did you try to define a new content in Tickers.spark (<use
content="nested_styles" />) and to use it from view instead of
recalling <content name="styles"> ?

Rob G

unread,
Jul 9, 2010, 11:59:59 AM7/9/10
to spar...@googlegroups.com
You could also potentially use this trick:


Regards,
Rob

--
You received this message because you are subscribed to the Google Groups "Spark View Engine Dev" group.
To post to this group, send email to spar...@googlegroups.com.
To unsubscribe from this group, send email to spark-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spark-dev?hl=en.


TMFReason

unread,
Jul 13, 2010, 12:16:34 PM7/13/10
to Spark View Engine Dev
That use of macros was nice to see as I've barely considered them as a
tool so far. But I think that implementation still has the same issue
of the nested masters being rendered after the view resulting in the
wrong reference order.

It maybe could be resolved by adding a top master so that all
references render in reverse order, then use insert rather than add,
but complicated by needing to do adds to keep the order in the same
page (if that makes sense). I have some additional complications in
that I'm not writing out simple tags, but partial views that localize
and may be one file or a defined group.

So I'll stick with using nested content elements rather than trying to
reuse the same name.

Reply all
Reply to author
Forward
0 new messages