TheLarkInn / angular2-template-loader

Chain-to loader for webpack that inlines all html and style's in angular2 components.
MIT License
205 stars 70 forks source link

Is your documentation right? #60

Closed dland512 closed 7 years ago

dland512 commented 7 years ago

I'm having trouble understanding your documentation. The code snippet given is

@Component({
  selector: 'awesome-button',
  template: require('./button.template.html'),
  styles: [require('./button.style.css')]
})
export class AwesomeButtonComponent { }

But then right below that it says

The angular2-template-loader searches for templateUrl and styleUrls declarations inside of the Angular 2 Component metadata and replaces the paths with the corresponding require statement

So why does the example use template and styles? What am I not getting here?

dland512 commented 7 years ago

I don't think it's quite right yet. You're "before" example still uses the template and styles properties when it should be using templateUrl and styleUrls.

GiuseppePiscopo commented 7 years ago

Was going to open a PR just for this. It seems wrong to me as well, but of course ... I might be wrong.

The way I see it, readme should look something like:


Before loader (your original code)

@Component({
  selector: 'awesome-button',
  templateUrl: 'button.template.html',
  styleUrls: ['button.style.css']
})
export class AwesomeButtonComponent { }

After loader (before it is bundled into your webpack'd application)

@Component({
  selector: 'awesome-button',
  template: require('./button.template.html'),
  styles: [require('./button.style.css')]
})
export class AwesomeButtonComponent { }
GiuseppePiscopo commented 7 years ago

Looking at current specs, my understanding seems to be ok:

dland512 commented 7 years ago

@GiuseppePiscopo, that's in line with my understanding as well. Hopefully your PR will get merged soon.