/// <summary>
        /// Replaces all hard {{{data_fieldname}}} and soft {{data_fieldname}} fields if mached with <c>data</c>  PropertyCollection key values.
        /// </summary>
        /// <param name="template">Any string that has {{{}}} template tags within</param>
        /// <param name="data">Collection with <c>key</c> values matching template tags</param>
        /// <param name="removeUnMatched">If TRUE it will remove all remaining/unmached tags. Use this if collection is the last PropertyCollection to apply</param>
        /// <returns>String with matched template tags replaced with content from <c>data</c> collection</returns>
        public static String applyToContent(this String template, PropertyCollection data, Boolean removeUnMatched = false)
        {
            reportTemplatePlaceholderCollection plc = new reportTemplatePlaceholderCollection();

            plc.loadTemplateString(template);
            return(plc.applyToContent(data, template, removeUnMatched));
        }
        /// <summary>
        /// Creates placeholder collection
        /// </summary>
        /// <param name="template">The template.</param>
        /// <returns></returns>
        public static reportTemplatePlaceholderCollection getPlaceHolders(this String template)
        {
            reportTemplatePlaceholderCollection plc = new reportTemplatePlaceholderCollection();

            plc.loadTemplateString(template);
            return(plc);
        }
        /// <summary>
        /// Applies the dataset on the line
        /// </summary>
        /// <param name="line">The line.</param>
        /// <param name="arg">The argument.</param>
        /// <param name="dataSets">The data sets.</param>
        /// <returns></returns>
        internal string applyLine(string line, docScriptArguments arg, PropertyCollection[] dataSets)
        {
            string cline = line.applyToContent(false, dataSets);

            if (cline.isTemplate())
            {
                keyListForFailedStrings.AddUnique(arg);
                reportTemplatePlaceholderCollection plcs = cline.getPlaceHolders();
                foreach (KeyValuePair <string, reportTemplatePlaceholder> plcp in plcs)
                {
                    missingData.AddUnique(plcp.Key);
                }
            }
            return(cline);
        }
        /// <summary>
        /// Replaces all template placeholder fields if mached with <c>data</c>  PropertyCollection key values.
        /// </summary>
        /// <param name="template">Any string that has {{{}}} template tags within</param>
        /// <param name="dataset">Multiple PropertyCollection or IEnumerable collections with PropertyCollection instances</param>
        /// <param name="removeUnMatched">If TRUE it will remove all remaining/unmached tags in the last iteration / PropertyCollection supplied.</param>
        /// <returns>String with matched template tags replaced with content from <c>data</c> collection.</returns>
        /// <remarks>
        /// It uses internally <see cref="reportTemplatePlaceholderCollection"/> for template mechanism.
        /// You may provide any and multiple IEnumerable PropertyCollection collections as part of <c>dataset</c> params array.
        /// </remarks>
        /// <example>
        /// <code>
        ///     String templateString = "His is {{{title}}} {{{first_name}}} {{{last_name}}} working with {{{company_name}}}."
        ///     String output = templateString.applyToContent(true, contactBean, accountBean);
        /// </code>
        /// Where <c>contactBean</c> and <c>accountBean</c> contain data from a corporate CRM.
        /// </example>
        /// <example>
        /// <code>
        ///     String output = templateString.applyToContent(true, contactBean, allCrmBeans, accountBean);
        /// </code>
        /// Where <c>allCrmBeans</c> is IEnumerable with multiple PropertyCollection instances.
        /// </example>
        public static String applyToContent(this String template, Boolean removeUnMatched, params PropertyCollection[] dataset)
        {
            PropertyCollection[] data = dataset.getFlatArray <PropertyCollection>();
            String mContent           = template;

            var dcl = data.Last();

            // plc.loadTemplateString(template);
            if (template.isTemplate())
            {
                reportTemplatePlaceholderCollection plc = new reportTemplatePlaceholderCollection(template);

                foreach (PropertyCollection dc in data)
                {
                    mContent = plc.applyToContent(dc, mContent, ((dcl == dc) && removeUnMatched));
                }
            }

            return(mContent);
        }