haml中的处理流程如何工作? [英] how does processing flow in haml work?
问题描述
我有一个run.haml文件,用于运行测试服.一切正常,但我想在用户单击将他引至该haml的链接后立即显示文本正在启动测试套件:#{params ['run']}".
I have a run.haml file where I run a test suit. Everything works just fine but I want to display the text "Starting test suite: #{params['run']}" immediately after user clicks the link that leads him to this haml.
点击的链接告诉haml需要执行什么诉讼
the link clicked tells haml what suit needs to be executed
%a(href="run?run=#{file}")
现在,测试服运行完成后,所有内容都会显示.将一直加载run.haml页面,直到脚本完成.
Right now everything is displayed after the test suit run finishes. The run.haml page is being loaded till the script finishes.
- halm 处理流程如何工作?
- 页面开始呈现后我可以开始处理作业吗?
- 我可以在浏览器中显示一些文本吗?然后让我们打电话给测试服吗?
- how does the haml processing flow work?
- can I start processing the job after the page starts rendering?
- can I display some text in a browser and then let call the test suit?
完成测试服的运行需要几分钟的时间.
It takes minutes to finish the run of the test suit.
!!!
%html
%head
%title Running
%body
= "Starting test suite: #{params['run']}"
- output = %x[cd C:\\Program Files\\TestPro\\TestPro Automation Framework410 && ant -lib lib -f "C:\\Program Files\\TestPro\\TestPro Automation Framework410\\Output Files\\builds\\#{params['run']}.xml"]
-#The result is
%br
= output.split("\n")[-2,2].join("<BR>")
= "<br/>"*2
%a(href="/")back to suits list
推荐答案
好吧,看-我的想法是,直到该函数调用返回后,它才呈现所有内容(无论出于何种原因).
Well, look -- my thought here is that it's not rendering everything (for whatever reason) until that function call returns.
在这种情况下,您需要与加载测试工具页面分开处理该函数的结果-因此,您将要使用
If that's the case, you'll want to process the result of that function separately from loading the test harness page -- so, you'll want to invoke the test suite either with
- Ajax调用,或者
- 单独的工作线程
- an Ajax call or,
- a separate worker thread
该选择取决于函数(通常)运行的时间长度-因此,根据复杂程度,对于 run_later 或 delayed_job ,甚至是自定义守护程序.
That choice depends on the length of time the function (generally) takes to run -- so, depending on the complexity, it may be a good candidate for something like BackgrounDRb, run_later or delayed_job, or even a custom daemon.
最后,您可能会发现将Sinatra与delay_job结合使用的示例很有帮助.
Finally, you may find this example of using Sinatra with delayed_job helpful.
这篇关于haml中的处理流程如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!