“渲染视图"是什么意思?这是什么程序? [英] What does it mean to "render a view"? What the procedure is this?

查看:97
本文介绍了“渲染视图"是什么意思?这是什么程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白什么是渲染视图".我正在阅读 Zend Framework 手册,这个术语有很多用法.

I can't understand what is "rendering a view". I'm reading Zend Framework manual and there are a lot of usage of this term.

自动渲染视图:

这个助手负责将视图对象注入到控制器,以及自动渲染视图.

This helper takes care of injecting the view object into the controller, as well as automatically rendering views.

禁用视图渲染:

您也可以简单地禁用单个视图的渲染

You can also simply disable rendering for an individual view

render() 渲染视图脚本.

render() 渲染视图脚本.

render() renders a view script.

在子目录中渲染该模板

为 $action 传递一个值将在/[controller]/子目录.

Passing a value for $action will render that template in the /[controller]/ subdirectory.

等等.

我找到了 render() 方法.事实上,Zend_Controller 的许多组件类都有 render() 方法.但最终所有这些都只调用 Zend_View_Abstract 类中的一个.我在它的实现中唯一能看到的是它似乎只是将 html 脚本放入输出缓冲区:

I found the render() method. I fact many component classes of Zend_Controller have render() method. But all of them at long last anyway call only the one from the Zend_View_Abstract class. And the only thing I could see in its realization is that it seems it just puts the html-script into the output buffer:

public function render($name) {

        // find the script file name using the parent private method
        $this->_file = $this->_script($name);
        unset($name); // remove $name from local scope

        ob_start();
        $this->_run($this->_file);

        return $this->_filter(ob_get_clean()); // filter output
    }

不幸的是没有实现 _run() 方法,我不知道它必须做什么,如何在范围中包含脚本.这就是包含 - include_once("/myScritp.php") 的意思吗?

Unfortunately there is no realization of the _run() method and I don't know what it has to do, how to include script in a scope. Is this what is meant by include - include_once("/myScritp.php")?

/**
 * Use to include the view script in a scope that only allows public
 * members.
 *
 * @return mixed
 */
 abstract protected function _run();

那么渲染视图"是什么意思?只是为了包含脚本并将其放入输出缓冲区并将其放入某个变量中(return ob_get_clean())然后呢?

So what does it mean to "render a view"? Just to include the script and put it into the output buffer and get it in some variable (return ob_get_clean()) then?

推荐答案

Zend Framework 基于 MVC 设计模式,代表模型视图控制器.视图是展示部分,包括 html、javascript、css 或任何其他美学.

Zend Framework is based on MVC design pattern which stands for Model View Controller. The View is presentation part including html, javascript, css or any other aesthetics.

渲染视图意味着向用户或浏览器显示一个视图,例如 html 部分.假设您有一个用于站点的关于"页面的控制器,现在从您的控制器呈现关于"视图,这意味着在浏览器中显示该页面以供用户查看,否则,如果您不这样做,用户将只见空白页 :)

Rendering a view means showing up a View eg html part to user or browser. Let's say you have a controller for About page of your site, now from your controller you would render the About view which means show the that page in browser for users to see otherwise if you don't users will see just blank page :)

想想它echo html/css/js 到浏览器.

Think of it echoing html/css/js to browser.

这篇关于“渲染视图"是什么意思?这是什么程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆