Amount to words Odoo qweb report for Purchase Requisition - numbers

I am trying to achieve amount to words in odoo 10. I am overriding the purchase requisition template. I will share my .py and .xml files please check what am I doing wrong. Thanks in advance!
Step1: Created module with scaffold command.
Step2: model.py
# -*- coding: utf-8 -*-
from odoo import models, fields, api
from openerp import models, api _
from openerp.tools import amount_to_text_en
from openerp import tools
from openerp.tools.amount_to_text import amount_to_text
class purchase_agreement_updates(models.Model):
_name = 'purchase_agreement_updates.purchase_agreement_updates'
_inherit = 'self.header'
#api.multi
def amount_to_text(self, amount, currency='Euro'):
return amount_to_text(amount, currency)
purchase_agreement_updates()
class purchase_requisition(models.Model):
_inherit = 'purchase.requisition'
#api.multi
def amount_to_text(self, amount, currency='Euro'):
return amount_to_text(amount, currency)
templates.xml:
<t t-name="purchase_requisition.report_purchaserequisitions">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<!--<t t-call="report.external_layout">-->
<div class="header">
<div style="float:left;width:100px;"></div>
<div style="margin:0 auto;width:100%;">
<h3 style="text-align:center;text-decoration: underline;margin-top:50px;">PURCHASE REQUISITION</h3></div>
<div style="float:right;width:100px;">
<img t-if="res_company.logo" t-att-src="'data:image/png;base64,%s' %res_company.logo" height="120px" width="100px"/></div>
<!--<t t-esc="o.name"/>-->
</div>
.
.
.
.
.
.
<tr t-foreach="o.line_ids" t-as="line_ids">
<t t-set="total_value" t-value="total_value+line_ids.product_qty * line_ids.price_unit"/>
<td style="border:1px solid #000;padding-left:5px;height:25px;"><span t-esc="line_ids_index+1"/> </td>
<td style="border:1px solid #000;padding-left:5px;height:25px;"><span t-field="line_ids.product_id.name"/></td>
<td style="border:1px solid #000;padding-left:5px;height:25px;"><span t-field="line_ids.product_qty"/> </td>
<td style="border:1px solid #000;padding-left:5px;height:25px;"><span t-field="line_ids.price_unit"/> </td>
<td style="border:1px solid #000;padding-left:5px;height:25px;"><span t-esc="line_ids.product_qty * line_ids.price_unit"/> </td></tr>
<tr><td style="border:1px solid #000;padding-left:5px;height:25px;"> </td>
<td style="border:1px solid #000;padding-left:5px;height:25px;"> </td>
<td style="border:1px solid #000;padding-left:5px;height:25px;"> </td>
<td style="border:1px solid #000;padding-left:5px;height:25px;">Total </td>
<td style="border:1px solid #000;padding-left:5px;height:25px;"> <t t-esc="total_value"/></td></tr>
<tr><td style="border:1px solid #000;padding-left:5px;height:25px;" colspan="5"><span style="font-weight:bold;">TOTAL PURCHASE:</span> <t t-esc="total_value"/> </td></tr>
<tr><td style="border:1px solid #000;padding-left:5px;height:25px;" colspan="5"><span style="font-weight:bold;">TOTAL PURCHASE IN WORDS:</span> <span t-esc="o.amount_to_text(total_value, 'Aed')"/>
<!--<span t-esc="o.amount_to_text('2000', o.currency_id)"/>--> </td></tr>
Error:
Error to render compiling AST
AttributeError: 'purchase.requisition' object has no attribute 'amount_to_text'
Template: 844
Path: /templates/t/t/t/t/div[2]/table[2]/tr[5]/td/span[2]
Node:

You don't need to do any kind of override. Each currency record has this function builtin. If you have multi-currency setup then the order_id of purchase.requisition or the company or user should have the reference to currency. Decide which currency you want to use Or you can get the default currency id in qweb and call currency_id.amount_to_text(o.amount_total). Here currency_id is the reference to currency object.

I think the issue is understanding what model is represented by your line_ids.
Your report captures the object(s) it is representing as an object "o" for each object in the parameter "docs" which is passed to the report rendering function.
t-foreach="docs" t-as="o"
The report is now busy rendering as per your xml for the object "o" and is then iterating over each of the line_ids found within the object "o".
t-foreach="o.line_ids" t-as="line_ids"
I did not see what model each "line_ids" corresponded to however that model must have the function
def amount_to_text()
My suspicion is that your function is not in the proper model and if you want to execute the function you must move it to the correct model.

Dear Phillip thank you very much for your detailed reply.
The solution worked for me is like this and as I mentioned in my question I am using odoo 10.
Models.py :
# -*- coding: utf-8 -*-
from odoo import models, fields, api
import num2words
class purchase_requisition(models.Model):
_inherit = 'purchase.requisition'
def conv(self, val):
return num2words.num2words(val)
templates.xml :
<span t-esc="o.conv(total_value)" style="text-transform:uppercase;"/>

from odoo.tools import amount_to_text_en
amt_in_words = fields.Char(compute='set_amt_in_words')
def set_amt_in_words(self):
for each in self:
amount, currency = each.amount_total, each.currency_id.name
amount_in_words = amount_to_text_en.amount_to_text(amount, lang='en', currency=currency)
if currency == 'INR':
amount_in_words = str(amount_in_words).replace('INR', 'rupees')
amount_in_words = str(amount_in_words).replace('Cents', 'paise')
amount_in_words = str(amount_in_words).replace('Cent', 'paise')
amount_in_words += '\tonly'
each.amt_in_words = amount_in_words.title()
XML :
<span t-esc="o.amt_in_words"/>

#api.multi
def amount_to_text(self, amount, currency='INR'):
amount_in_words = amount_to_text_en.amount_to_text(amount, lang='en', currency=currency)
if currency == 'INR':
amount_in_words = str(amount_in_words).replace('INR', 'rupees')
amount_in_words = str(amount_in_words).replace('Cents', 'paise')
amount_in_words = str(amount_in_words).replace('Cent', 'paise')
amount_in_words += '\tonly'
return amount_in_words
def get_amount_in_words(self, amount):
amount_in_words = self.amount_to_text(amount)
return amount_in_words
and the xml -

Related

invoice report - display discount in Line invoice - Odoo 12 - Qweb

I am making a report for the invoice line, I have purchased a module in the third-party odoo store and it performs its function well.
But I can't see the discount on the invoice line.
I think this is because the module prevents me, but I already have no developer support.
What I need is that the discount (price list) can be seen on the invoice line.
What table or what element of the invoice line discount?
I leave you the code that I have in the report
''''
<tbody class="invoice_tbody">
<tr t-foreach="invoice_lines[0]" t-as="line">
<td><b><span t-esc="line['client_ref']"/></b>
<span t-esc="line['description']"/></td>
<td class="text-right">
<span t-esc="line['qty']"/>
</td>
<td class="text-right">
<span t-esc="line['price_unit']"/>
</td>
<td t-if="display_discount" class="text-right">
</td>
<td class="text-right" id="subtotal">
<t t-if="line['price_subtotal']">
<span t-esc = "line ['price_subtotal']" t-options = "{& quot; widget & quot ;: & quot; monetario & quot ;, & quot; display_currency & quot ;: o.currency_id}" /> </t>
</td>
</tr>
<tr t-foreach = "range (max (5-len (o.invoice_line_ids), 0))" t-as = "l">
<td t-translation = "off"> & amp; nbsp; </td>
<td class = "hidden" />
<td />
<td />
<td t-if = "display_discount" />
<td />
<td />
</tr>
</tbody>
</t>
'''
Yes, this parameter is in the report
"view / report_invoice_document"
But the report that I try to modify is this
report_invoice_document_inherit
<?xml version="1.0"?>
<data inherit_id="account.report_invoice_document">
<xpath expr="//table[#name='invoice_line_table']/tbody" position="replace">
<t t-if="res_company.is_group_by_so">
<t t-set="invoice_lines" t-value="o.get_invoice_lines()"/>
<tbody class="invoice_tbody">
<tr t-foreach="invoice_lines[0]" t-as="line">
<td><b><span t-esc="line['client_ref']"/></b>
<span t-esc="line['description']"/></td>
<!-- <td class="hidden"><span t-esc="line['client_ref']"/></td> -->
<td class="text-right">
<span t-esc="line['qty']"/>
<!-- <span t-field="l.uom_id" groups="product.group_uom"/> -->
</td>
<td class="text-right">
<span t-esc="line['price_unit']"/>
</td>
</td>
<td t-if="display_discount" class="text-right">
<!-- <span t-esc="line['price_unit']"/> -->
</td>
<td class="text-right" id="subtotal">
<t t-if="line['price_subtotal']">
<span t-esc="line['price_subtotal']" t-options="{"widget": "monetary", "display_currency": o.currency_id}"/></t>
</td>
</tr>
<tr t-foreach="range(max(5-len(o.invoice_line_ids),0))" t-as="l">
<td t-translation="off">&nbsp;</td>
<td class="hidden"/>
<td/>
<td/>
<td t-if="display_discount"/>
<td/>
<td/>
</tr>
</tbody>
</t>
<t t-else="">
<tbody class="invoice_tbody">
<tr t-foreach="o.invoice_line_ids" t-as="l">
<td><span t-field="l.name"/></td>
<td class="hidden"><span t-field="l.origin"/></td>
<td class="text-right">
<span t-field="l.quantity"/>
<span t-field="l.uom_id" groups="product.group_uom"/>
</td>
<td class="text-right">
<span t-field="l.price_unit"/>
</td>
<td t-if="display_discount" class="text-right">
<span t-field="l.discount"/>
</td>
<td class="text-right">
<span t-esc="', '.join(map(lambda x: (x.description or x.name), l.invoice_line_tax_ids))"/>
</td>
<td class="text-right" id="subtotal">
<span t-field="l.price_subtotal" t-options="{"widget": "monetary", "display_currency": o.currency_id}"/>
</td>
</tr>
<tr t-foreach="range(max(5-len(o.invoice_line_ids),0))" t-as="l">
<td t-translation="off">&nbsp;</td>
<td class="hidden"/>
<td/>
<td/>
<td t-if="display_discount"/>
<td/>
<td/>
</tr>
</tbody>
</t>
</xpath>
</data>
I have tried to modify the second report, and put and have looked at the python code in case something
invoice_report_grouped_by \ report \ account_invoice.py
# -*- coding: utf-8 -*-
from odoo import api, models
from datetime import datetime
class AccountInvoice(models.Model):
_inherit = "account.invoice"
def get_notation_amt(self, amt):
'''This method help us to return the value of the product pricing'''
amount = str(amt).split('.')
if len(amount) == 2:
amount = amount[0] + "," + amount[1]
return amount
return amt
#api.multi
def get_product_invoice_lines(self, client_ref=False):
'''This method helps to get the data for the following Invoice Line.'''
product_invoices = []
client_order_ref = []
for line in self.invoice_line_ids:
sale_line = (False, line)
if line.sale_line_ids:
sale_line = (line.sale_line_ids[0].order_id, line)
client_order_ref.append(sale_line)
if client_order_ref:
for ref in client_order_ref:
if (client_ref == ref[0]):
product_invoices.append({'price_subtotal': ref[1].price_unit * ref[1].quantity,
'default_code': ref[1].product_id.default_code,
'client_ref': False,
'discount': ref[1].discount,
'taxes': ",".join(map(lambda x: (x.description or x.name), ref[1].invoice_line_tax_ids)),
'description': ref[1].name,
'qty': self.get_notation_amt(ref[1].quantity),
'price_unit': self.get_notation_amt("{0:.3f}".format(ref[1].price_unit)),
})
else:
for line in self.invoice_line_ids:
product_invoices.append({'price_subtotal': line.price_unit * line.quantity,
'default_code': line.product_id.default_code,
'client_ref': False,
'discount': line.discount,
'taxes': ",".join(map(lambda x: (x.description or x.name), ref[1].invoice_line_tax_ids)),
'description': line.name,
'qty': self.get_notation_amt(line.quantity),
'price_unit': self.get_notation_amt("{0:.3f}".format(line.price_unit)),
})
return product_invoices
#api.multi
def get_invoice_lines(self):
'''This method help to get the invoice line group by Sale order'''
vals = []
sale_order_lines = []
false_sale_order_lines = []
for line in self.invoice_line_ids:
sale_line = False
if line.sale_line_ids:
sale_line = line.sale_line_ids[0].order_id
if sale_line:
sale_order_lines.append(sale_line)
else:
false_sale_order_lines.append(sale_line)
sale_order_lines = list(set(sale_order_lines))
false_sale_order_lines = list(set(false_sale_order_lines))
for sale_order in sale_order_lines:
if sale_order and self.origin:
confirmation_date = str(
sale_order.confirmation_date, '%d-%m-%Y %H:%M:%S').strftime('%d/%m/%Y')
client_ref = sale_order.name + ' - ' + confirmation_date
if sale_order.client_order_ref:
client_ref = client_ref + ' - ' + sale_order.client_order_ref
vals.append({'price_subtotal': False, 'default_code': False,
'client_ref': client_ref, 'description': False,
'qty': False, 'price_unit': False, 'taxes': False, 'discount': False})
vals.extend(self.get_product_invoice_lines(client_ref=sale_order))
# for sort false sale order, display manually invoice line at last
for so in false_sale_order_lines:
vals.extend(self.get_product_invoice_lines(client_ref=so))
return [vals, len(vals)]
You can see the default report here:
https://github.com/odoo/odoo/blob/06f9baae968674547cb2592b1c22147bfb2e8ba9/addons/account/views/report_invoice.xml#L49
<t t-set="display_discount" t-value="any([l.discount for l in o.invoice_line_ids])"/>
This means that if any line has a discount, it should display it.
I think there are two options to disable it. One is to remove that line from the report, or the second option is to set display_discount to false.
Knowing the module that breaks your report, the problem should be easy to find.
But the exact reason is hard to tell without seeing your module.

how can i parse html in flutter?

I am using Flutter and want to parse HTML using parser.dart
<div class="weather-item now"><!-- now -->
<span class="time">Now</span>
<div class="temp">19.8<span>℃</span>
<small>(23℃)</small>
</div>
<table>
<tr>
<th><i class="icon01" aria-label="true"></i></th>
<td>93%</td>
</tr>
<tr>
<th><i class="icon02" aria-label="true"></i></th>
<td>south 2.2km/h</td>
</tr>
<tr>
<th><i class="icon03" aria-label="true"></i></th>
<td>-</td>
</tr>
</table>
</div>
Using,
import 'package:html/parser.dart';
I want to get this data
Now,19.8,23,93%,south 2.2km/h
How can I do this?
Since you are using the html package, you can get the desired data like so using some html parsing and string processing (as needed), here is a dart sample, you can use the parseData function as is in your flutter application -
main.dart
import 'package:html/parser.dart' show parse;
main(List<String> args) {
parseData();
}
parseData(){
var document = parse("""
<div class="weather-item now"><!-- now -->
<span class="time">Now</span>
<div class="temp">19.8<span>℃</span>
<small>(23℃)</small>
</div>
<table>
<tr>
<th><i class="icon01" aria-label="true"></i></th>
<td>93%</td>
</tr>
<tr>
<th><i class="icon02" aria-label="true"></i></th>
<td>south 2.2km/h</td>
</tr>
<tr>
<th><i class="icon03" aria-label="true"></i></th>
<td>-</td>
</tr>
</table>
</div>
""");
//declaring a list of String to hold all the data.
List<String> data = [];
data.add(document.getElementsByClassName("time")[0].innerHtml);
//declaring variable for temp since we will be using it multiple places
var temp = document.getElementsByClassName("temp")[0];
data.add(temp.innerHtml.substring(0, temp.innerHtml.indexOf("<span>")));
data.add(temp.getElementsByTagName("small")[0].innerHtml.replaceAll(RegExp("[(|)|℃]"), ""));
//We can also do document.getElementsByTagName("td") but I am just being more specific here.
var rows = document.getElementsByTagName("table")[0].getElementsByTagName("td");
//Map elememt to its innerHtml, because we gonna need it.
//Iterate over all the table-data and store it in the data list
rows.map((e) => e.innerHtml).forEach((element) {
if(element != "-"){
data.add(element);
}
});
//print the data to console.
print(data);
}
Here's the sample output -
[Now, 19.8, 23, 93%, south 2.2km/h]
Hope it helps!
This article would probably be of help. It specifically uses the html package parser.
Following the example in the package's readme you can easily obtain a Document object. With this object you can obtain specific Elements of the DOM with methods like getElementById, getElementsByClassName, and getElementsByTagName. From there you can obtain the innerHtml of each Element that is returned and put together the output string you desire.

Selenium Webdriver_Not able to click on link given into column

I'm a beginner and I'm trying to write a Selenium web driver. I'm using eclipse and trying to locate a link available in next column. In each row I have different link. For example in my employee data table I have 2 columns and 10 rows in one page. The first column contains the name of person and second column contains its employee ID (ID is a hyperlink). I'm trying to select the hyperlink of any employee but I'm not able to do it.
I have below the HTML code and sample script.
<span id="37">
<div class="clear"></div>
<div id="FC_Schema.1021.WIP" type="DataCheckingList" name="FC_Schema.1021.WIP">
<input id="baseurl" type="hidden" value="/Web/" name="baseurl">
<input id="hdnDcCnt" type="hidden" value="13" name="hdnDcCnt">
<input id="PageNo" type="hidden" value="1" name="PageNo">
<meta content="width=device-width" name="viewport">
<style type="text/css">
<div id="DataCheckingLoad">
<div id="SupplyChainTabs">
<div id="gbo" class="InnerAlertsTabs">
<table id="one" class="draggable" width="100%">
<thead>
<tbody>
<tr>
<td valign="top" align="center">
<td valign="top">
<td valign="top">
<a onclick="return ButtonClick(this,'TxnyD.Communities.2.1','Org.2000476_Product.THQS|SMS|Questionnaire.WIP_Questionnaire_TxnyD.Communities.2.1_THQS_TxnyD.Operationaloffice.1.2');" href="#f">Axiom
Process LLC</a>
<div class="country-name">
<div class="CompanyInfoContactLinks">
</td>
<td valign="top">
THQS
<div class="clear"> </div>
<a id="Org.2000476_Product.THQS|SMS|Questionnaire.WIP_Questionnaire_TxnyD.Communities.2.1_THQS_TxnyD.Operationaloffice.1.2" onclick="RedirectToQuestionnairePage(id)" href="#">THQS</a>
<div class="clear"> </div>
</td>
In the above code first column contains company name i.e "Axiom
Process LLC" and second column contains company subcription name i.e."THQS". I have to select the THQS link of company "Axiom Process LLC"
Selenium script designed for it as below
public static void main(String[] args) throws Exception {
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.get("http://XXX.XXX.XXX.XXX/Web");
Thread.sleep(1000);
driver.findElement(By.xpath("//input[#id='UserName']")).sendKeys("Gbouser.1");
driver.findElement(By.xpath("//input[#id='Password']")).sendKeys("****");
driver.findElement(By.xpath("//input[#name='Login']")).click();
driver.findElement(By.xpath("//a[contains(text(),'Task')]")).click();
driver.findElement(By.xpath("//a[contains(text(),'Data Checking')]")).click();
driver.findElement(By.partialLinkText("Axiom")).findElement(By.xpath("//a[contains(text(),'THQS')]")).click();
}
So basically these are dynamic tables and each time it will have different records. How can select the link available in column?
I also tried below script as well:
driver.findElement(By.name("*[id^='CLS'][id$='Demolition Limited']")).findElement(By.xpath("//a[contains(text(),'THQS')])[3]")).click();
welcome to Stackoverflow. Before answering your question, just a few pointers. Think that you had a downvote 'cause you didn't format your question well. Otherwise a perfectly legal question, and you would receive help much earlier.
Secondly, don't ever put the real Web site address, username and password :). I was able to login, and understand exactly what you need, but a malicious guy could do bad wonders there.
To answer your question, instead of the line that is causing you problems, try this
Thread.sleep(3000);
TablePageObject tablePageObject = PageFactory.initElements(driver, TablePageObject.class);
tablePageObject.clickLink("Axiom");
Where TablePageObject is
public class TablePageObject {
private WebDriver driver;
#FindBy(css = "table tr")
private List<WebElement> allTableRows; // find all the rows of the table
public TablePageObject(WebDriver driver) {
this.driver = driver;
}
public void clickLink(String companyName) {
for(WebElement row : allTableRows) {
List<WebElement> links = row.findElements(By.cssSelector("a"));
// the first link by row is the company name, the second is link to be clicked
if (links.get(0).getText().contains(companyName)) {
links.get(3).click();
}
}
}
}
An explanation, TablePageObject class will be your programmatic handle for the dynamic table you're trying to control. It follows a page factory pattern of selenium, which I heartly recommend, and you can learn more here https://code.google.com/p/selenium/wiki/PageFactory
It basically keeps a collection of rows of your table, which more or less looks like:
<tr>
<td valign="top" align="center">
// irelevant
</td>
<td valign="top">
// irelevant
</td>
<td valign="top">
<a>Axiom Process LLC</a>
<a>company details</a>
<a>web details</a>
</td>
<td valign="top">
<a>THQS</a>
</td>
<td valign="top" align="center" style="display: none">
// irelevant
</td>
<td valign="top">
//irelevant
</td>
<td valign="top">
// irelevant
</td>
<td valign="top">
</td>
<td>
</td>
</tr>
You collect all the links from the table, check the company name against the first link, and if matched, click the fourth link,
Hope it helps, best,
by the way, I've masked your password in the question

Comet tables with Lift 2.4 and HTML5

I'm trying to dynamically update a HTML table via Comet. I've got something like the following:
class EventsComet extends CometClient[Event] {
def server = Event
def render = {
println("Binding on: " + defaultHtml)
data.flatMap( event =>
bind("event", "name" -> event.name.toString, "date" -> event.startDate.toString)
)
}
}
And:
<lift:comet type = "EventsComet">
<table>
<thead>
<tr>
<th>Name</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<tr>
<td><event:name />Test Name</td>
<td><event:date />Oct. 25, 2012</td>
</tr>
</tbody>
</table>
</lift:comet>
This prints out the entire table over and over again, one for each event rendered by EventsComet. The println statement outputs the entire table node.
So I tried variations:
<table>
<thead>
<tr>
<th>Race</th>
<th>Track</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<lift:comet type = "EventsComet">
<tr>
<td><event:name />Test Name</td>
<td><event:date />Oct. 25, 2012</td>
</tr>
</lift:comet>
</tbody>
</table>
As expected, the HTML5 parser strips out the [lift:comet] tags and no binding occurs.
So I tried switching the rows to:
<tr lift:comet = "EventsComet">
<td><event:name />Test Name</td>
<td><event:date />Oct. 25, 2012</td>
</tr>
...as is shown in a snippet example here, but with this syntax my CometClient is not being instantiated at all.
Can anyone advise on the proper syntax?
EventsComet itself works fine; it can keep lists of events up to date without problem. I only run into issue using tables (and presumably other highly-nested structures I've not tried yet?).
Thank you. This is all rather frustrating for such a simple problem, and makes me want to just start implementing my templates in a strongly-typed templating language instead of using bindings.
The proper syntax seems to be:
<tr class="lift:comet?type=EventsComet">
<td><event:name />Test Name</td>
<td><event:date />Oct. 25, 2012</td>
</tr>
From this thread:
https://groups.google.com/forum/?fromgroups=#!topic/liftweb/NUDU1_7PwmM
Sometimes I'm getting duplicate rows (inserted above the table header at that), but I'd imagine this is related to my comet actor itself.

Variable within scala template in play framework

I need to be able to declare variables and after some markup later I
need to reference them. In order to accomplish this, this is
simplified version of my scala template:
#(map1:
java.util.LinkedHashMap[String,java.util.LinkedHashMap[String,Object]])
#import scala.collection.JavaConversions._
#import play.Logger
#for( (key,value) <- map1) {
<div>
#{
val rmap = Foo.someMethod(value)
val baz = rmap.getOrElse("baz", null)
<table border="0" cellpadding="0" cellspacing="0" >
<tbody>
<tr>
<td rowspan="3">
<div class="bar">
#baz
</div>
</td>
</tr>
</tbody>
</table>
}
</div>
}
Is above valid scala template and if not how can I declare baz and
reference it later in the markup?
I am using 1.2.2RC2 and scala 0.9.1
I was curious so did some digging. See https://groups.google.com/forum/#!topic/play-framework/Mo8hl5I0tBQ - there is no way at the moment, but an interesting work-around is shown. Define utils/Let.scala:
package utils
Object Let {
def let[A,B](a:A)(f:A=>B):B = f(a)
}
and then
#import utils.Let._
#let(2+3){ answer =>
#answer <hr> #answer
}
It's a very functional way of handling it, but then, what'd you expect in Scala :)
You can just use a for comprehension:
#for( (key,value) <- map1;
rmap = Foo.someMethod(value);
baz = rmap.getOrElse("baz", null)
) {
<div>
<table border="0" cellpadding="0" cellspacing="0" >
<tbody>
<tr>
<td rowspan="3">
<div class="bar">
#baz
</div>
</td>
</tr>
</tbody>
</table>
</div>
}
... and if you don't have anything you need to loop over, you can just say #for(i <- List(1); <declare variables>){<html here>}