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

Add support for ASP.NET .cshtml templates #22

Closed
wants to merge 1 commit into from
Closed

Add support for ASP.NET .cshtml templates #22

wants to merge 1 commit into from

Conversation

tatyshev
Copy link

No description provided.

@tatyshev tatyshev changed the title .cshtml strategy for asp.net mvc applications Add support for ASP.NET .cshtml templates May 18, 2014
@rubenv
Copy link
Owner

rubenv commented May 19, 2014

Do you have a sample file so that we can add a test case?

@mkeuschn
Copy link

Hi,

I have added the cshtml support to the extractor (cshtml: 'html',). And used it in a partial view of my project. It works as desired.

report.cshtml:

<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
    <table class="table table-condensed table-responsive">
        <thead>
            <tr>
                <th translate>activity</th>
                <th translate>hours</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            <tr ng-repeat="item in $parent.items">
                <td ng-style="{'background-color': '{{item.color}}', 'color' : 'white'}">{{item.name}}</td>
                <td ng-style="{'background-color': '{{item.color}}', 'color' : 'white'}">{{item.value}}</td>
                <td ng-style="{'background-color': '{{item.color}}', 'color' : 'white'}">{{item.relative}} %</td>
            </tr>
        </tbody>
    </table>
</div>

Do you need a project, a normal view file or is the partial view file enough?

regards

@rubenv
Copy link
Owner

rubenv commented Jun 25, 2014

The file you just specified is plain HTML. Does ASP.NET have any special markup or tags? If so, we'll need a sample with that.

@mkeuschn
Copy link

I have added the layout page as exmaple. There is a little bit of the Razor syntax inside.

regards

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title</title>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")
    <meta name="description" content="The description of my page" />
</head>
    <body data-ng-app="ManagementReporting">
        <input type="hidden" id="application-data" data-server-root-path="@HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority)@Url.Content("~/")" />
        <div class="navbar navbar-default navbar-fixed-top" data-ng-controller="NavbarController">
            <div class="container">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    @Html.ActionLink("Management Reporting", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
                </div>
                <div class="navbar-collapse collapse">
                    <ul class="nav navbar-nav">
                        <li><a href="#/"><span translate>DashBoard</span></a></li>
                        <li><a href="#/Template/Index">Template</a></li>
                    </ul>
                    <ul class="nav navbar-nav navbar-right">
                        <li class="dropdown">
                            <a id="language-selector" role="button" data-toggle="dropdown" data-target="#" href="javascript:void(0);">
                                <img class="flag" src="{{language.img}}" />
                                {{language.name}} <span class="caret"></span>
                            </a>
                            <ul class="dropdown-menu" role="menu" aria-labelledby="language-selector">
                                <li ng-repeat="language in languages">
                                    <img class="flag flag-dropdown" src="{{language.img}}" />
                                    <span data-ng-click="setLanguage(language.iso)">{{language.name}}</span>
                                </li>
                            </ul>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="container body-content">
            @RenderBody()
        </div>
        <div id="footer">
            <div class="container">
                <p class="text-muted">&copy; @DateTime.Now.Year - Company</p>
            </div>
        </div>

        @Scripts.Render("~/bundles/jquery")
        @Scripts.Render("~/bundles/bootstrap")
        @Scripts.Render("~/bundles/angular")
        @Scripts.Render("~/bundles/angular-gettext")
        @Scripts.Render("~/bundles/linq")
        @Scripts.Render("~/bundles/angular")
        @Scripts.Render("~/bundles/ui.bootstrap")
        @Scripts.Render("~/bundles/highstock")
        @Scripts.Render("~/bundles/moment")
        @Scripts.Render("~/bundles/ManagementReporting")
        @RenderSection("scripts", required: false)
    </body>
</html>

@vladimir-poleh
Copy link

I can confirm that this fix is suitable for ASP.NET MVC layout files.

Sample file:

@using MyApp.tools
@model ApplicationData
<!DOCTYPE html>
<html id="ng-app" ng-app="myApp">
<head>
    <meta charset="utf-8">
    <title>@Model.BrowserTitle</title>
    @Html.Action("JavaScriptThirdPartyLibraries")
    @Html.Action("CSSFiles")

@if (!string.IsNullOrEmpty(Model.BrandingCss))
    {
        <link href='@Url.GetHashedUrl(Model.BrandingCss)' rel="stylesheet" media="screen">
    }

    <script src='@Url.GetHashedUrl("controller/ContactController.js")' type="text/javascript"></script>
    <script src='@Url.GetHashedUrl("script/translations.js")' type="text/javascript"></script>
</head>

<body>
@* Server side comment *@
    <div class="container" ng-controller="contactController">
        <div class="row-fluid">
            <div class="panel-content panel-padding clearfix">
                <h1 translate>Contact Us</h1>
                <p translate>We've worked hard to make the <a ng-click="FAQ()">FAQs</a> as helpful as possible. Please check our FAQ as we may have an answer for you, before you reach out to our Customer Support team.</p>
                <h4 translate>Still can't find the answer?</h4>
                <p><a href="mailto:[email protected]" translate>Send us an email</a></p>
                <h4 translate>Hours of Operation</h4>
                <p translate>8:00 am - 5:00 pm PT, Weekdays</p>
                <h4 translate>Email Response Time</h4>
                <p translate>We do our best to respond to email inquiries within <strong>3 business days</strong>, although this can vary when we're experiencing higher than normal volume.</p>
            </div>
        </div>
    </div>
</body>

@rubenv
Copy link
Owner

rubenv commented Aug 5, 2014

Great, now we'll just need to turn this into a test case and it can go in.

@Jak3b0
Copy link

Jak3b0 commented Sep 15, 2014

Hi,

Is this will be pulled into the main branch?

gabegorelick added a commit to gabegorelick/angular-gettext-tools that referenced this pull request Dec 9, 2014
Closes rubenv#22, rubenv#40, and probably others
@tatyshev tatyshev closed this Dec 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants