Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import helpers from FubuMVC.Core.UI #7

Open
jeremydmiller opened this issue Mar 26, 2014 · 2 comments
Open

Import helpers from FubuMVC.Core.UI #7

jeremydmiller opened this issue Mar 26, 2014 · 2 comments

Comments

@jeremydmiller
Copy link
Contributor

    public static HtmlTag Text(this HtmlTag tag, StringToken token)
    {
        return tag.Text(token == null ? string.Empty : token.ToString());
    }

    public static HtmlTag Attr(this HtmlTag tag, string attName, StringToken token)
    {
        return tag.Attr(attName, token.ToString());
    }

    public static T TextIfEmpty<T>(this T tag, StringToken token) where T : HtmlTag
    {
        return tag.TextIfEmpty(token.ToString());
    }

    /// <summary>
    ///   Just returns the localized header text for a property of the view model
    /// </summary>
    /// <typeparam name = "T"></typeparam>
    /// <param name = "page"></param>
    /// <param name = "expression"></param>
    /// <returns></returns>
    public static string HeaderText<T>(this IFubuPage<T> page, Expression<Func<T, object>> expression)
        where T : class
    {
        return LocalizationManager.GetHeader(expression);
    }
@jeremydmiller
Copy link
Contributor Author

    [Test]
    public void set_localized_tag_text_by_string_token()
    {
        var token = StringToken.FromKeyString("KEY", "the text of this string token");
        new HtmlTag("a").Text(token)
            .Text().ShouldEqual(token.ToString());
    }

    [Test]
    public void set_localized_attr_value_by_string_token()
    {
        var token = StringToken.FromKeyString("KEY", "the text of this string token");

        new HtmlTag("span").Attr("title", token)
            .Attr("title").ShouldEqual(token.ToString());
    }

@jeremydmiller
Copy link
Contributor Author

    [Test]
    public void set_the_text_by_localized_StringToken()
    {
        var token = StringToken.FromKeyString("KEY", "the localized string");
        new HtmlTag("div").TextIfEmpty(token)
            .Text().ShouldEqual(token.ToString());
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant