Giter VIP home page Giter VIP logo

templating's Introduction

Build Status

Angular Templating

The templating engine for Angular 2.0.

Setup

  1. npm install
  2. npm install -g gulp
  3. npm install -g bower
  4. npm install -g protractor
  5. bower install

Running the examples

  1. gulp build watch serve
  2. Go to http://localhost:8000/dist/amd/example/index.html

Unit tests

  1. Unit tests: karma start

E2e tests

  1. Start the server: gulp build watch serve
  2. Start and download webdriver: webdriver-manager start
  3. Run the tests: protractor

Code Style Guide

  • Use 2 spaces as tab, see .editorconfig

templating's People

Contributors

btford avatar caitp avatar eisenbergeffect avatar igorminar avatar tbosch avatar vojtajina avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

templating's Issues

Selectors should support XML Namespace URIs, too

Well, maybe they should.

I left a comment on #1 (comment):

I don't have time right now to give a proper review, but I was wondering if it might also make sense to add selectors for XML namespaces, to assist in supporting SVG and MathML stuff? I guess if we need that it could be added later on, but it seems like a good idea

It may or may not be worth it, but it seems like a potentially useful thing

docs(readme): incomplete instructions

Following the instructions in the readme will not put the developer's machine in a state where it can run the tests. Two steps need to be added:

  1. npm install -g karma
  2. npm install -g karma-cli

Note: sudo needed on linux

Also, it is unclear how to run the examples. Simply opening helloworld.html in Firefox results in script errors. In the past, I've been able to run require.js-based projects just fine directly from the file system via Firefox. Something about the current configuration does not work. Please provide instructions for how to run the examples.

Add code coverage

I am working on a project with a similar setup to this repo. I'm trying to use the traceur preprocessor for karma along with the istanbul coverage preprocessor and I ended up finding this issue on the istanbul repo. I'm opening an issue here so that...

  1. There's a place to track automated coverage for the angular templating repo
  2. I'll be notified once this repo has implemented a solution.

I imagine this problem will pop up a lot more when angular 2.0 is released. Thanks.

Deleting todos adds listeners?

Easier to see if you increase the number of todos to about 20~

The number of listeners (from the chrome dev tool -> timeline) doubles after deleting all todos. I think ngZone is holding the references, but I'm not sure.

Bug: Data-bound Directive Attributes Don't Work Without Duplication

Currently, in order to data-bind to the value of an attribute with the same name as its corresponding directive, you must duplicate the directive. So, for ng-repeat you must do the following:

<div ng-repeat="" bind-ng-repeat="items"></div>

Only the second attribute should be necessary.

Bug(view): Cannot watch collections.

The method View.watch is missing a parameter. Please add a collection:bool parameter.

Internally it is hard-coded to pass false to the watch parser for the collection indicator. This value should be passed from the View.watch method parameters instead. Without this capability it is not possible to implement ngRepeat.

Bug(event_handler): Duplicate invocations of handlers.

Run the helloworld sample you will see the bug. Add a couple of different items. Then start invoking the "Add" button. You will see that the incCounter() is invoked a number of times equal to the node's index (+1). So if you have three items, and you click "Add" on the third item, the function will be invoked three times. (Actually, as I was writing this, I discovered that the behavior isn't consistent. It's also dependent on what button was clicked previously.)

In addition to this, there's also some dirty checking issues going on. You will notice that clicking the button doesn't always result in an update. Sometimes you will need to click another button to see the original sum update.

Server side Rendering

I already commented about that in the docs, but will post this here again as I think this issue has a greater visibility:

Why isn't server-side rendering a design goal? It would improve performance for (mobile) apps due to a better initial load time and increases compatibility with existing services (say saving a page from an Angular app to Pocket or indexing by search engines). Angulars templates and directives are often misused because of this - many people use data-binding to translate their apps even if these translations are static and not dynamic. The same happens for templates. A lot of these have static components (e.g. some ng-includes in some apps are never changed while running the app - they are just used to inline static HTML which could happen in a pre-compile step or on server side, too). I think some people call this "bind-once", but I think this is only half of the story if "bind-once" doesn't work server-side, too. And... it would be great if two-way data-bindings would be prefilled with the right values on the server-side while pushing the initial app to the browser, so you don't get "content flickering". Some people call this isomorphic JavaScript.

Link to the disscusion in the docs.

I also had a short discussion with @bradlygreen on Google+ about this topic where he stated that the "server side rendering" feature request is mostly about SEO and that this would be a solved topic and that data should be inlined to get a fast initial response:

I don't think SEO is a solved problem. As far as I understand escaped_fragment it only works for SPAs based on Angular, not for Angular code which is embedded in existing (read: legacy) pages.

Not everything can be inlined in the first template, because a lot of people misuse data-binding (e.g. for translation, even if the translated strings aren't changed at runtime and therefor are static). This unnecessarily defers execution of the app. You can - and should - precompile things like that with a different templating engine, but this often conflicts with Angular templates syntax wise and developers need to use and learn an additional templating engine.

It makes it harder to reuse code (e.g. for validation) on the server side, too. Of course I could refactor my validation code to a non-angular-based framework and than reuse it in my controllers, filter, whatever, but I can't use them out of the box and I couldn't reuse i18n filter which are already in Angulars core.

This aside it would would be super handy if I could use directives and precompile them e.g. like a static site generator. I know this is not the focus of Angular, but than I could reuse my Angular code for a lot more projects. Say I have a with an ng-repeat inside. The controller to switch the carousel items is static and will be released for a static site or a SPA alike, but ng-repeat would only be executed if is filled with real time data. If it just filled with a static JSON it could be precompiled and the generated markup is just plain vanilla HTML - or it would check async for new data and is therefor only pre-filled with data to stop "content flickering". Something which is a problem for dynamic SPAs, too.

Thank you.

Bug(samples): Incorrect casing in head links.

The helloworld.html file contains new references to third party libraries. The casing for the folder name does not match what is present on the disk. This causes problems on some operating systems. Please change as follows:

<link rel="stylesheet" href="/third_party/brick/brick-1.0.1.byob.css">
  <script src="/third_party/brick/brick-1.0.1.byob.js"></script>

Note: It should be all lowercase.

Regarding img src attribute issue

I just watched that video and I am confused regarding the issue with the 'src' atttribute described by Rob Eisenberg at 39m30s
http://youtu.be/cwXZ0YFvpzs?t=39m30s

In Google Polymer I can do exactally <img src='{item.imgsrc}/> inside a template that and there is no erroneous http requests. The src gets evaluated only when the template is actually added to the visible DOM.

Feature: Separate View Instantiation from ExecutionContext Targeting

At present, to create a view, you must supply an execution context. Afterwards, this context is permanently tied to the view. We should separate these two things so that we can re-use view instances by re-targeting them to a different execution context. There are two primary use cases off the top of my head:

  1. The router can use this to optimize rendering of frequently accessed routes. This can be done by implementing the router's corresponding directive to cache views internally and re-target them to different controller instances. In fact, any template directive could use this technique (even allowing caching behavior to be configured by the developer).
  2. Performant, infinitely scrolling lists will want to create a number of view instance up front and re-use those instances by simply re-targeting each template item to different data and using some css3 transforms.

bug(loader): check for existing loader plugins when patching RequireJS

The loader.js attempts to patch require.js by detecting all HTML files and prepending the module id with a custom loader plugin. However, it may be that files with an html extension have been explicitly required by the developer and aren't intended to be turned into view factories. To fix, detect whether the module id is already prepended by a loader plugin and bypass if it is.

Missing feature: life cycle / turn

  • digest and flush, with 2 watchGroups, dom read/dom write/async queue
  • digest:
    • processes 1 watchGroup and async queue
  • flush:
    • processes 1 watchGroup and dom read/dom write queue
  • flush watchGroup:
    • for observers whose reaction function only changes the DOM and no one else will change that part of the DOM during flush.
    • purpose: optimize digest cycles

Also: When a change event for a DOM property is triggered, execute the reaction function of watches for that property directly .

Feature: Enable Watch Disabling on Views

This relates to issue #26. In order to enable caching and re-use of views, a template directive needs to be able to turn off watches on a particular view instance without destroying the view. It may be that this can be handled by simply setting the execution context to null via an API provided by #26.

Update "dist" releases, tag when "stable"

So, it's been about 5 months since the last "dist" release was updated, and there are almost no tagged releases yet.

@EisenbergEffect / @tbosch do you think you guys could pick out some suitably stable commits for tagging so that prototypes can be built against relatively recent changes to the code? Not necessarily the bleeding edge, but just stable "enough" to be useful, I guess.

Missing feature: add filters

Filters should be defined just like directives via a class that has the @Filter annotation, e.g. @Filter({name:'multiply'}).

In a template, only those filters should be allowed in expressions that are provided via the <module> tag, just like directives (resp. when calling compile manually the allowed filter classes need to be given as an argument to compile).

Open questions:

  • when a directive calls view.watch(expr...), which filters can this expression contain? Would the directive need to provide the filters as an argument to watch?
  • on which injector are filters registered? On the root injector or on the view's injector?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.