Friday, April 10, 2009

Testing code snippets

This is just a post to test the procedure described on kello.se to enable proper code formatting in blogger. I would prefer a full blown css driven syntax highlighting solution but this will have to do for now I guess. Just to verify the functionality, here is a short snippet from a small authz solution I've written in grails.


def listUsersByRole = {
def users = User.list()
def role = new Role()
def validUsers = []
role.authorityCode = params.rollkod
role.scope = params.orgkod
for (user in users) {
if(user.hasRole(role)) {
validUsers << user
}
}
.... render view etc ...
}


N.B the code above is highlighted with a js/css script solution from http://code.google.com/p/syntaxhighlighter/. I'm seeing some strangeness in Firefox with the nice labels etc. But it looks good enough so I'll keep using it.

0 comments: