Check if Page component has a layout property; and if yes, wrap the page
into the specified layout, then render to a string.
344896
function renderToString(page) {
  var layout = null, child = null, props = {};
  while ((layout = page.type.layout || (page.defaultProps && page.defaultProps.layout))) {
    child = React.createElement(page, props, child);
    _.extend(props, page.defaultProps);
    React.renderToString(React.createElement(page, props, child));
    page = layout;
  }
  return React.renderToString(React.createElement(page, props, child));
}
946715
def render_template(view, template, layout_name, locals)
        render_with_layout(view, template, layout_name, locals) do |layout|
          instrument(:template, identifier: template.identifier, layout: layout.try(:virtual_path)) do
            template.render(view, locals) { |*name| view._layout_for(*name) }
          end
        end
      end
1167929
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WColumn col = (WColumn) component;
		XmlStringBuilder xml = renderContext.getWriter();

		xml.appendTagOpen("ui:column");
		xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendOptionalAttribute("track", component.isTracking(), "true");
		int width = col.getWidth();
		xml.appendOptionalAttribute("width", width > 0, width);

		switch (col.getAlignment()) {
			case LEFT:
				// left is assumed if omitted
				break;

			case RIGHT:
				xml.appendAttribute("align", "right");
				break;

			case CENTER:
				xml.appendAttribute("align", "center");
				break;

			default:
				throw new IllegalArgumentException("Invalid alignment: " + col.getAlignment());
		}

		xml.appendClose();

		// Paint column contents
		paintChildren(col, renderContext);

		xml.appendEndTag("ui:column");
	}
544510
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WPanel panel = (WPanel) component;
		XmlStringBuilder xml = renderContext.getWriter();
		GridLayout layout = (GridLayout) panel.getLayout();
		Size hgap = layout.getHorizontalGap();
		String hgapString = hgap == null ? null : hgap.toString();
		Size vgap = layout.getVerticalGap();
		String vgapString = vgap == null ? null : vgap.toString();
		int rows = layout.getRows();
		int cols = layout.getCols();

		xml.appendTagOpen("ui:gridlayout");

		xml.appendAttribute("rows", rows > 0 ? String.valueOf(rows) : "0");
		xml.appendAttribute("cols", cols > 0 ? String.valueOf(cols) : "0");
		xml.appendOptionalAttribute("hgap", hgapString);
		xml.appendOptionalAttribute("vgap", vgapString);

		xml.appendClose();

		int size = panel.getChildCount();

		for (int i = 0; i < size; i++) {
			xml.appendTag("ui:cell");
			WComponent child = panel.getChildAt(i);
			child.paint(renderContext);
			xml.appendEndTag("ui:cell");
		}

		xml.appendEndTag("ui:gridlayout");
	}
77145
function getLayout(layout) {
    if (!layoutCache.hasOwnProperty(layout)) {
      var layoutContents = false,
          layoutPath = path.join(
        path.isAbsolute(options.layoutPath) ?
          options.layoutPath : path.join(process.cwd(), options.layoutPath),
        layout
      );
      try {
        layoutContents = fs.readFileSync(layoutPath, 'utf8');
      } catch (err) {
        throw new PluginError(logFlag, 'Could not read layout: \'' + layoutPath + '\'\n');
      }
      layoutCache[layout] = {
        contents: layoutContents,
        path: layoutPath
      };
    }
    return layoutCache[layout];
  }
119653
def render_page
      respond_to do |format|
        format.html do
          render action: :show, layout: !request.xhr?
        end

        format.rss do
          if @page.contains_feed?
            render action: :show, layout: false, handlers: [:builder]
          else
            render xml: {error: 'Not found'}, status: 404
          end
        end
      end
    end
43622
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WPanel panel = (WPanel) component;
		XmlStringBuilder xml = renderContext.getWriter();
		ColumnLayout layout = (ColumnLayout) panel.getLayout();
		int childCount = panel.getChildCount();
		Size hgap = layout.getHorizontalGap();
		String hgapString = hgap == null ? null : hgap.toString();
		Size vgap = layout.getVerticalGap();
		String vgapString = vgap == null ? null : vgap.toString();
		int cols = layout.getColumnCount();

		xml.appendTagOpen("ui:columnlayout");
		xml.appendOptionalAttribute("hgap", hgapString);
		xml.appendOptionalAttribute("vgap", vgapString);
		xml.appendClose();

		// Column Definitions
		for (int col = 0; col < cols; col++) {
			xml.appendTagOpen("ui:column");
			int width = layout.getColumnWidth(col);
			xml.appendOptionalAttribute("width", width > 0, width);

			switch (layout.getColumnAlignment(col)) {
				case LEFT:
					// left is assumed if omitted
					break;

				case RIGHT:
					xml.appendAttribute("align", "right");
					break;

				case CENTER:
					xml.appendAttribute("align", "center");
					break;

				default:
					throw new IllegalArgumentException("Invalid alignment: " + layout.
							getColumnAlignment(col));
			}

			xml.appendEnd();
		}

		for (int i = 0; i < childCount; i++) {
			xml.appendTag("ui:cell");
			WComponent child = panel.getChildAt(i);
			child.paint(renderContext);
			xml.appendEndTag("ui:cell");
		}

		xml.appendEndTag("ui:columnlayout");
	}
769874
function render(element, opts) {
    opts = opts || {};

    var prepend = opts.prepend;
    var model = opts.model || {};
    var indentLevel = opts.indentLevel || 0;
    var isPretty = opts.isPretty;
    var jtPrintIndent = isPretty ? '\t' : '';
    var jtPrintNewline = isPretty ? '\n' : '';
    var indent = '', i, len, prop;
    var p = [];  // p is going to be our concatenator for the HTML string

    // if no element, then no HTML so return empty string
    if (!element) { return ''; }

    // if already a string, just return it
    if (utils.isString(element)) { return element; }

    // if an array, wrap it
    if (utils.isArray(element)) { element = naked(element, null); }

    // set the indentation level to the current indent
    if (isPretty && indentLevel) {
        for (i = 0; i < indentLevel; i++) {
            indent += jtPrintIndent;
        }
    }

    // if we are prepending some string, add it first
    if (prepend) {
        p.push(indent, prepend, jtPrintNewline);
    }

    // starting tag open
    if (element.tag) {
        p.push(indent, '<', element.tag);
    }

    // all tag attributes
    if (element.attributes) {
        for (prop in element.attributes) {
            if (element.attributes.hasOwnProperty(prop)) {

                if (element.attributes[prop] === null) {
                    p.push(' ', prop);
                }
                else {
                    p.push(' ', prop, '="', element.attributes[prop], '"');
                }
            }
        }
    }

    // if no children or text, then close the tag
    if (element.tag && !element.children && (element.text === undefined || element.text === null)) {

        // for self closing we just close it, else we add the end tag
        if (selfClosing.indexOf(element.tag) > -1) {
            p.push('/>', jtPrintNewline);
        }
        else {
            p.push('></', element.tag, '>', jtPrintNewline);
        }
    }
    // else we need to add children or the inner text
    else {

        // if a tag (i.e. not just a string literal) put end bracket
        if (element.tag) { p.push('>'); }

        // if children, we will need to recurse
        if (element.children) {
            if (element.tag) { p.push(jtPrintNewline); }

            // recurse down for each child
            for (i = 0, len = element.children.length; i < len; ++i) {
                p.push(render(element.children[i], {
                    indentLevel:    element.tag ? indentLevel + 1 : indentLevel,
                    isPretty:       isPretty,
                    model:          model
                }));
            }

            if (element.tag) { p.push(indent); }
        }

        // if text, simply add it
        if (element.text !== null && element.text !== undefined) { p.push(element.text); }

        // finally if a tag, add close tag
        if (element.tag) {
            p.push('</', element.tag, '>', jtPrintNewline);
        }
    }

    return p.join('');
}
468388
private void renderRecipe() throws IOException {
		StringBuilder sb = new StringBuilder();

		// First pages
		if( ! Constants.GENERATED.equalsIgnoreCase( this.applicationTemplate.getName())) {
			sb.append( renderDocumentTitle());
			sb.append( renderPageBreak());

			sb.append( renderParagraph( this.messages.get( "intro" ))); //$NON-NLS-1$
			sb.append( renderPageBreak());

			sb.append( renderDocumentIndex());
			sb.append( renderPageBreak());

			sb.append( startTable());
			sb.append( addTableLine( this.messages.get( "app.name" ), this.applicationTemplate.getName())); //$NON-NLS-1$
			sb.append( addTableLine( this.messages.get( "app.qualifier" ), this.applicationTemplate.getVersion())); //$NON-NLS-1$
			sb.append( endTable());

			sb.append( renderApplicationDescription());
			sb.append( renderPageBreak());
			sb.append( renderSections( new ArrayList<String>( 0 )));

		} else {
			sb.append( renderDocumentIndex());
			sb.append( renderPageBreak());
		}

		// Render information about components
		sb.append( renderComponents());

		// Render information about facets
		sb.append( renderFacets());

		writeFileContent( sb.toString());
	}
279295
function() {

		 // Render the help panel
	    this.renderHelpPanel();

	    /**
	     * @property layout
	     * @type {YAHOO.widget.Layout}
	     */
	    this.layout = new widget.Layout(this.el, this.options.layoutOptions);
	    this.layout.render();

		 // Right accordion
	    this.renderPropertiesAccordion();

	    // Render buttons
	    this.renderButtons();

	 	 // Saved status
		 this.renderSavedStatus();

	    // Properties Form
	    this.renderPropertiesForm();

  }
1229571
private static boolean isPageInTemplateDefinition(Page page) {
    Resource resource = page.adaptTo(Resource.class);
    if (resource != null) {
      Resource parent = resource.getParent();
      if (parent != null) {
        return StringUtils.equals(NT_TEMPLATE, parent.getValueMap().get(JCR_PRIMARYTYPE, String.class));
      }
    }
    return false;
  }
1115983
@Override
    protected void renderTagEnd() {
        try {
            if (StringUtils.isNotEmpty(this.output)) {
                this.output = toString(this.escape
                        ? escape(this.output)
                        : this.output);
                JspWriter writer = this.pageContext.getOut();
                boolean renderTag = renderTag()
                        && (StringUtils.isNotBlank(this.tagName) || StringUtils.isNotBlank(getClasses()));
                if (renderTag) {
                    super.renderTagStart();
                }
                writer.write(this.output);
                if (renderTag) {
                    super.renderTagEnd();
                }
            }
        } catch (IOException ioex) {
            LOG.error(ioex.getMessage(), ioex);
        }
    }
205064
@Override
    public Page renderPage(String providerName, Map<String, Object> params)
    {
        if (!configMode)
            return super.renderPage(providerName, params);
        else
            return getPage();
    }
431547
function PageRenderer(req, res) {
    var page = req.attrs.page;
    Object.defineProperties(this, {
        req: {
            value: req
        },
        res: {
            value: res
        },
        page: {
            value: _.clone(page)
        },
        themeDBAction: {
            value: DBActions.getInstance(req, THEME_SCHEMA)
        },
        layoutDBAction: {
            value: DBActions.getInstance(req, LAYOUT_SCHEMA)
        },
        pageInstanceDBAction: {
            value: DBActions.getAuthInstance(req, PAGE_SCHEMA, PAGE_PERMISSION_SCHEMA)
        },
        pluginInstanceDBAction: {
            value: DBActions.getInstance(req, PLUGIN_INSTANCE_SCHEMA)
        },
        pagePermissionValidator: {
            value: new PermissionValidator(req, PAGE_PERMISSION_SCHEMA, PAGE_SCHEMA)
        },
        pluginPermissionValidator: {
            value: new PermissionValidator(req, PLUGIN_PERMISSION_SCHEMA, PLUGIN_INSTANCE_SCHEMA)
        },
        isExclusive: {
            value: req.query && req.query.mode === "exclusive"
        }
    });
}
280918
function Render()
    {
        self::$currentPage = $this->page;
        self::$Title = self::$currentPage->GetTitle();
        self::$Description = self::$currentPage->GetDescription();
        self::$Keywords = self::$currentPage->GetKeywords();
        if ($this->page->GetType() == (string)PageType::NotFound())
        {
            header('HTTP/1.0 404 Not Found');
        }
        else if ($this->page->GetType() !== (string)PageType::Normal())
        {
            throw new \Exception('Internal phine error: not normal page called');
        }
        ob_start();
        require PathUtil::LayoutTemplate($this->layout);
        $result = ob_get_clean();
        $replacer = new Replacer();
        return $replacer->RealizeVariables($result);
    }
1213595
protected function displayInner() {
    if ($this->_template)  {
      // Get the layout from a template file
      extract($this->_vars);
      include($this->_template);
    }
    else {
      // Echo each child in order
      foreach ($this->_vars as &$child)
        if ($child instanceof Component)
          $child->display();
        else
          echo $child;
    }
  }
907316
function errorPage(res, errMsg, publicMsg, useLayout) {
	if ( useLayout === undefined ) useLayout = true;
	console.log(errMsg);
	res.render('error', {
		layout: useLayout,
		errMsg: errMsg,
		publicMsg: publicMsg
	});			
}