Title: Feature: embedded TypeScript syntax (a'la EJS) · Issue #2846 · microsoft/TypeScript · GitHub
Open Graph Title: Feature: embedded TypeScript syntax (a'la EJS) · Issue #2846 · microsoft/TypeScript
X Title: Feature: embedded TypeScript syntax (a'la EJS) · Issue #2846 · microsoft/TypeScript
Description: There are plenty of template engines for JS - but to my knowledge, there is currently no template engine that provides any meaningful level of IDE support, e.g. for view-models written in TypeScript. In fact, most template engines don't ...
Open Graph Description: There are plenty of template engines for JS - but to my knowledge, there is currently no template engine that provides any meaningful level of IDE support, e.g. for view-models written in TypeScrip...
X Description: There are plenty of template engines for JS - but to my knowledge, there is currently no template engine that provides any meaningful level of IDE support, e.g. for view-models written in TypeScrip...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/2846
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Feature: embedded TypeScript syntax (a'la EJS)","articleBody":"There are plenty of template engines for JS - but to my knowledge, there is currently no template engine that provides any meaningful level of IDE support, e.g. for view-models written in TypeScript. In fact, most template engines don't provide auto-completion or any kind of checking for view-models at all - so when it comes to editing views, you're really no better off with view-models than you are with plain view-dictionary hashes.\n\nIn other words, the only viable option for IDE support, for views, at this time, is to use a DSL and stay in TypeScript, which comes with it's own set of drawbacks.\n\nPlease consider adding an alternative file-extension (e.g. `.ets`) for TypeScript embedded in text (or markup) a'la [EJS](http://www.embeddedjs.com/), ERB (Ruby), Go templates, PHP, etc. - most every web-language has one.\n\nBasic example:\n\n```\n${{ declare var view: ArticleView }}\n\u003c!DOCTYPE html>\n\u003chtml>\n\u003chead>\n \u003ctitle>${view.title}\u003c/title>\n\u003c/head>\n\u003cbody>\n \u003carticle>\n \u003ch1>${view.headline}\u003c/h1>\n ${view.body}\n \u003c/article>\n\u003c/body>\n\u003c/html>\n```\n\nSo basically, `${expr}` emits the result of a TypeScript expression, and `${{ code }}` escapes to inline TypeScript code without emitting the result, with syntax that resembles that of string templates. In a sense, it's just string templates without the ceremony, e.g. with an intermediary interpretation along the lines of:\n\n```\nfunction _tpl(_fn) {\n return _fn`\u003c!DOCTYPE html>\n\u003chtml>\n\u003chead>\n \u003ctitle>${this.view.title}\u003c/title>\n\u003c/head>\n\u003cbody>\n \u003carticle>\n \u003ch1>${this.view.headline}\u003c/h1>\n ${this.view.body}\n \u003c/article>\n\u003c/body>\n\u003c/html>`;\n}\nexport = _tpl;\n```\n\nThat's by no means intended to be correct or complete - the main point is that:\n\n```\n1. the resulting function is a top-level export.\n2. the template function being used is supplied by the caller.\n3. the calling context is supplied by the caller.\n4. variable references are expanded relative to the calling context.\n```\n\nAny thoughts? (we are evaluating a switch from PHP to Node+TypeScript, and the biggest roadblock right now is the lacking design-time support for views - we're a large team that do a lot of template work, so this is critical.)\n","author":{"url":"https://github.com/mindplay-dk","@type":"Person","name":"mindplay-dk"},"datePublished":"2015-04-21T09:34:55Z","url":"https://github.com/microsoft/TypeScript/issues/2846"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1186e771-3bac-1ca7-f905-b5fccc68116f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9982:3F8AB1:A95518:DB0187:6B00E3ED |
| html-safe-nonce | 204e5530603dfa6a50bc9642d3fcb97f94a613fe13f920dbf718a914412a31d7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OTgyOjNGOEFCMTpBOTU1MTg6REIwMTg3OjZCMDBFM0VEIiwidmlzaXRvcl9pZCI6Ijc3MjM4MDcwMzkyOTc3NDE4MDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a74ac1a48574c6ae30713ac4c5ddf75db6fd21fe45ef042230f3bb55d4de920f |
| hovercard-subject-tag | issue:69796215 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/2846/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d752fcfa7df4f52bf8ee8e59e9bdb76471c0e03ad1088e63ad541851c78675ba/microsoft/TypeScript/issues/2846 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d752fcfa7df4f52bf8ee8e59e9bdb76471c0e03ad1088e63ad541851c78675ba/microsoft/TypeScript/issues/2846 |
| og:image:alt | There are plenty of template engines for JS - but to my knowledge, there is currently no template engine that provides any meaningful level of IDE support, e.g. for view-models written in TypeScrip... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mindplay-dk |
| hostname | github.com |
| expected-hostname | github.com |
| None | 27088b6977484d0d3321d9a11c907c6d6637b315cfa359ef7952dbf6292f9b14 |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 624179fb8b88d26ba5bba08894eb60a1c5a1d93d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width