Extending spark with custom attributes

2 views
Skip to first unread message

Sean Chambers

unread,
Aug 9, 2010, 7:27:42 PM8/9/10
to Spark View Engine Dev
I'm trying to gather some info to see if the following is possible
with spark. I stumbled across ISparkExtension but am not sur if it's
what I should use. Basically i have a fairly complex permission system
and am trying to minimize the intrusiveness of the permission system
by adding custom attributes to securable items like so:

<security entity="User" group="Edit" />
<div id="test" permission="view" ></div>

basically, the security node will be used by all page level security
checks, while the attributes on the HTML elements are used to dothe
actual security
check.

If the best way is to use ISparkExtension do I just not output
anything
if the security check fails, or is there a better approach here?

Thanks

Sean

Igor Loginov (aka ilog2000)

unread,
Aug 10, 2010, 9:07:20 AM8/10/10
to Spark View Engine Dev
Hi Sean,

I would make the following:
1. I'd make a HtmlHelper extension method, let's say
DivWithPermission(string innerHtml, string permission) with tag
rendering rules inside.
2. I would use a brand new Spark feature "Bindings" to create a
binding for <div> like this:
<element name="div">Html.DivWithPermission('child::*', '@permission')</
element>

After that it's possible to use permission attribute in your div in
Spark markup.

Warning! I've personally never tried this approach, so I don't know
the possible obstacles. But this way looks doable.

Igor Loginov (aka ilog2000)

unread,
Aug 10, 2010, 9:12:44 AM8/10/10
to Spark View Engine Dev
Oops! Forgot to add that I wold process the whole view permission not
in markup, but in controller using AuthorizeAttribute or marker
interfaces

On Aug 10, 3:07 pm, "Igor Loginov (aka ilog2000)" <ilog2...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages