Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8023401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:33:15+00:00 2026-06-04T22:33:15+00:00

I making a custom binding with a row template that should be optional. If

  • 0

I making a custom binding with a row template that should be optional. If the user does not supply a template id i want to use a default one, but it does not reside in a script tag in body, it’s just a string on the options literal.

How can i use a string as template?

the default template should be really easy something like this

<span data-bind="text: name"></span>

I’ve tried the ko.renderTemplate but it does only take id’s to script tags

ko.renderTemplate(template, bindingContext.createChildContext(data), null, row, "replaceChildren");

Update
Just got a notification about this question, and saw that there were people suggestion injecting the template to the dom and use the standard script tag provider. But this does not take into account that the user can override the default template source (Common scenario with single plage applications. I use this way, that first tries the default template provider and then fallbacks to the string template source like this

var engines: {}
var renderTemplate = function (element, template, data, bindingContext) {
    var engine = engines[template];

    var success = false;
    do {
        try {
            ko.renderTemplate(template, bindingContext.createChildContext(data), engine, element, "replaceChildren");
            success = true;
            engines[template] = engine;
        } catch(err) {
            if (engine != null)
                throw "Template engine not found";

            engine = { templateEngine: stringTemplateEngine };
        }

    } while (!success)
};

Full code and stringTemplateEngine code can be found here
https://github.com/AndersMalmgren/Knockout.Combobox/blob/master/src/knockout.combobox.js#L297

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T22:33:16+00:00Added an answer on June 4, 2026 at 10:33 pm

    To render templates from strings you will need to write a custom template source as described here.

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a custom view that I want to be bindings/core data compatible and
I'm making a custom control that can be dragged around and it is semi
I'm making a custom error dialog in my WPF app and I want to
I am making a custom control I need to add some default keybindings, microsoft
I'm making a custom generator that generates a new rails app, and I do
So I'm making a custom window template for my WPF application. The trouble I'm
I am making custom NSScrollers for use in NSScrollView. But when any of the
I am making a custom CMS in PHP and I want to know what
When autoloading libraries, helpers or models, does this also hold true when making custom
Does making custom roms involve the same skill set as making apps? Are they

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.