Esempio n. 1
0
        /// <summary>
        /// Processes this instance.
        /// </summary>
        protected async virtual Task <bool> Process()
        {
            var text    = TagReference.InnerText;
            var ngModel = TagReference.GetAttributeValue("[(ngModel)]", null);

            var prefix = GenerateIdPrefix();

            //if the element is bound to an ng model, use that as an id else use the inner text
            if (ngModel != null)
            {
                TagReference.Id = prefix + "_" + ngModel.ToLower();

                return(true);
            }
            else if (!string.IsNullOrWhiteSpace(text))
            {
                var scrubbedText = Regex.Replace(text, "[" + InvalidCharacters + "]", "", RegexOptions.None, TimeSpan.FromSeconds(1.5));
                scrubbedText = Regex.Replace(scrubbedText, @"\s+", "").ToLower();

                TagReference.Id = prefix + "_" + scrubbedText;

                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        protected async override Task <bool> Process()
        {
            var ngClick = TagReference.GetAttributeValue("(click)", null);

            var prefix = GenerateIdPrefix();

            //if the element is bound to an ng model, use that as an id else use the inner text
            if (ngClick != null)
            {
                TagReference.Id = prefix + "_" + ReplaceInvalidChars(ngClick.ToLower());

                return(true);
            }

            return(false);
        }
Esempio n. 3
0
        protected async override Task <bool> Process()
        {
            var url = TagReference.GetAttributeValue("href", null);

            if (!string.IsNullOrWhiteSpace(url))
            {
                Uri parsedUri;
                var uri = Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out parsedUri);

                if (parsedUri != null)
                {
                    var lastSegment = parsedUri.Segments[parsedUri.Segments.Length - 1];
                    TagReference.SetAttributeValue("id", "link_" + lastSegment);
                    return(true);
                }
            }
            else
            {
                return(await base.Process());
            }

            return(false);
        }