template $for

28 views
Skip to first unread message

Dakshina R

unread,
Feb 14, 2019, 10:03:41 AM2/14/19
to web.py
Hello ,

I have two variables which has to be looped through simultaneously, so I used  the following : $for i,j in zip (devices,stat): , but it gives me an error as zip not defined.
So how do I loop through it simultaneously

Following is the HTML code:

$def with (stat,devices)
<!DOCTYPE html>
<html lang="en">
<head>
 
<title>Dashboard</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https:/
/maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
  <script src="
https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
 
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

  <style>
   
/* Remove the navbar's default margin-bottom and rounded borders */
   
.navbar {
      margin
-bottom: 0;
      border
-radius: 0;
      height
: 50%;
   
}

   
/* Set height of the grid so .sidenav can be 100% (adjust as needed) */
   
.row.content {height: 350px}

   
/* Set gray background color and 100% height */
   
.sidenav {
      padding
-top: 20px;
      height
: 100%;
   
}

   
/* On small screens, set height to 'auto' for sidenav and grid */
   
@media screen and (max-width: 767px) {
     
.sidenav {
        height
: auto;
        padding
: 10px;
     
} }
   
.button1 {
         background
-color: #4CAF50; /* Green */
        border
: none;
        color
: white;
        padding
: 15px 12px;
        text
-decoration: none;
        display
: inline-block;
        font
-size: 14px;
        margin
: 4px 2px;
        cursor
: pointer;
   
}
   
.button2 {
            background
-color: violet;
            border
: none;
            padding
: 15px 12px;
            text
-decoration: none;
            display
: inline-block;
            font
-size: 14px;

     
.row.content {height:auto;}
 font
-weight: bold;
            left
: 150px;
            margin
: 4px 2px;
            border
-radius: 8px;
            cursor
: pointer;
   
}


 
</style>
</
head><nav class="navbar navbar-inverse">
 
<div class="container-fluid">
   
<div class="navbar-header">
       
<i class="fa fa-home" style="font-size:50px;color:lightblue;text-shadow:2px 2px 4px #000000";> </i >
    </
div>
 
</div>
</
nav>

<div class="container-fluid text-center">
 
<div class="row content">
   
<div class="col-xs-2 sidenav">
     
<form action="/home_view">
       
<input type="submit" class="button1" value="Modes  " />
     
</form>
      <form action="/
room_view?Room" method="POST">
       <input type="
submit" class="button1"  value="Rooms  " />
      </form>
      <form action="
/panel_view">
       <input type="
submit" class="button1"  value="Sensors" />
      </form>
      <form action="
/settings">
       <input type="
submit" class="button1"  value="Settings" />
      </form>
    </div>
    <br><br>
    <div class="
col-xs-8">
 <form action="
#"  method="POST" >
              $for i
,j in zip (devices,stat):
                     
<input type="submit"  class="button2" name="$i"  value="$i"  style="color:$j" />
       
</form>

    </
div>
 
</div>
</
div>
</body>
</
html>


<body>

Shane Cleveland

unread,
Feb 15, 2019, 12:21:49 PM2/15/19
to web.py
Check out how to pass builtins and functions to templates: http://webpy.org/docs/0.3/templetor#builtins
Reply all
Reply to author
Forward
0 new messages