That's weird. I tried your code but I am unable to reproduce the html
you got <span style...>.

If "user_name" is what you need:

#view
{{if auth.is_logged_in:}}
{{=session.auth.user.name}}
{{pass}}



On Dec 8, 9:28 pm, Saurabh Kumar <saurabh.ca...@gmail.com> wrote:
> My view file looks like :
>
> {{extend 'layout.html'}}
> {{=user_name}}
> <div id="chat">
>         <div id="chatlines" style="margin: 5px; border: 1px solid
> rgb(22,44,22)">
>                 {{for line in lines:}}
>                         {{=line}}
>                 {{pass}}
>         </div>
>
>         <div id="chatform_box">
>                 <form id="chatform" onKeyPress="enter(event);">
>                         <fieldset>
>                                 <div>
>                                 <textarea cols="100" rows="3" 
> name="statement" id="statement"  /></
> textarea>
>                                         <input type="submit" value="chat" />
>                                 </div>
>                                 <div>
>                                         <select name="channel" id="channel">
>                                                 {{for channel in channels:}}
>                                                 <option 
> value="{{=channel.id}}"{{if channel.id==current:}}
> selected="selected"{{pass}}>{{=channel.name}}</option>
>                                                 {{pass}}
>                                         </select>
>                                 </div>
>                         </fieldset>
>                 </form>
>         </div>
> </div>
>
> My controller is like
>
> def rooms():
>        # Require the socket.IO file
>     response.files.append('http://cdn.socket.io/stable/
> socket.io.js')#URL('static','js/socket.io.js'))
>     response.files.append(URL('static', 'js/jquery.blockUI.js'))
>     staff=auth.has_permission('delete', 'chat')
>
>     lines=[]
>     for line in rawlines:
>         # Treat emote lines and other lines different from each other
>         clazz=(line.deleted!=None and 'chat-deleted') or ''
>         if line.emote:
>             lines.append(DIV(line.statement,_id=line.id,_class=clazz))
>         else:
>             lines.append(DIV(line.speaker.name, B(">"), " %s" %
> (line.statement, ),_id=line.id, _class=clazz))
>     # This puts the lines in the direction that makes more sense to
> read from top to bottom
>     lines.reverse()
>     # The list of channels available
>     channels=db().select(db.chat_channel.ALL)
>     # get logged in user name
>     s=db(db.auth_user.id==auth.user.id).select().first()
>     return
> dict(lines=lines,channels=channels,staff=staff,current=int(request.args[0]) 
> ,user_name=s.name)
>
> The browser receives a html code like
>
> <div id="page"> <!-- Here my central body -->
>
>  <!-- content -->
>  <div id="content" style="width: 100%" >
>
> <span style="color: rgb(30, 30, 30)">abc</span>
> <div id="chat">
> ..
> ...
>
> On Dec 8, 6:20 pm, lyn2py <lyn...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Saurabh,
>
> > >> {{=user_name}}
>
> > will only give:
>
> > >> something
>
> > in view, without the additional code (span, style etc that you
> > mentioned).
>
> > If it doesn't work for you, please show us the actual code that is not
> > performing as expected.
>
> > On Dec 8, 9:08 pm, Saurabh Kumar <saurabh.ca...@gmail.com> wrote:
>
> > > Thanks for you reply.
>
> > > But my controller is not that simple,
>
> > > The return statement actually looks like
>
> > >     return
> > > dict(lines=lines,channels=channels,staff=staff,current=int(request.args[0])
> > >  ,user_name=s.name)
>
> > > On Dec 8, 5:49 pm, Vinicius Assef <vinicius...@gmail.com> wrote:
>
> > > > In your controller, just return "something", without the dict().
>
> > > > [code]
> > > > return "something"
> > > > [/code]
>
> > > > On Thu, Dec 8, 2011 at 10:34 AM, Saurabh Kumar 
> > > > <saurabh.ca...@gmail.com> wrote:
> > > > > Hi,
>
> > > > > I am returning  a dict (user_name="something") from my controller.
>
> > > > > In my view, I am displaying it using {{=user_name}}
>
> > > > > It generates an html code like...
>
> > > > > <span style="color: rgb(30, 30, 30)">something</span>
>
> > > > > but I am looking for just
>
> > > > > something
>
> > > > > Can I modify the output of response.write to achieve this? Is there
> > > > > some other way to achieve this?
>
> > > > > Thanks
>
> > > > > Saurabh

Reply via email to