コード例 #1
0
        protected override void RenderControl(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            var resourceManager = context.ResourceManager;

            if (resourceManager.HeadRendered)
            {
                return;
            }
            // set the flag before the resources are rendered, so they can't add more resources to the list during the render
            resourceManager.HeadRendered = true;

            // render resource links and preloads
            ResourcesRenderer.RenderResources(resourceManager, writer, context, ResourceRenderPosition.Head);
        }
コード例 #2
0
        protected override void RenderControl(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            // render resource links
            var resourceManager = context.ResourceManager;
            if (resourceManager.BodyRendered) return;
            resourceManager.BodyRendered = true;  // set the flag before the resources are rendered, so they can't add more resources to the list during the render
            ResourcesRenderer.RenderResources(resourceManager, writer, context, ResourceRenderPosition.Body);

            // render the serialized viewmodel
            var serializedViewModel = ((DotvvmRequestContext) context).GetSerializedViewModel();
            writer.AddAttribute("type", "hidden");
            writer.AddAttribute("id", "__dot_viewmodel_root");
            writer.AddAttribute("value", serializedViewModel);
            writer.RenderSelfClosingTag("input");

            // init on load
            writer.RenderBeginTag("script");
            writer.WriteUnencodedText($@"
window.dotvvm.domUtils.onDocumentReady(function () {{
    window.dotvvm.init('root', {JsonConvert.ToString(CultureInfo.CurrentCulture.Name, '"', StringEscapeHandling.EscapeHtml)});
}});");
            writer.RenderEndTag();
        }
コード例 #3
0
ファイル: AmpBody.cs プロジェクト: MichalTichy/DotVVM.AMP
 protected override void RenderContents(IHtmlWriter writer, IDotvvmRequestContext context)
 {
     ResourcesRenderer.RenderResources(context.ResourceManager, writer, context, ResourceRenderPosition.Body);
     base.RenderContents(writer, context);
 }