{"_id":"@dellamina/ts-presenter","_rev":"3-6220ea42b4a5c6057d605a9e20167eb2","name":"@dellamina/ts-presenter","dist-tags":{"latest":"0.2.2"},"versions":{"0.2.1":{"name":"@dellamina/ts-presenter","version":"0.2.1","description":"Simple view presenters written in typescript using decorators.","main":"./lib/index.js","types":"./lib/index.d.ts","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"Mattia Della Mina"},"license":"ISC","gitHead":"447a1cb5b3def2932e9f65d210444339c32497f9","_id":"@dellamina/ts-presenter@0.2.1","_npmVersion":"5.6.0","_nodeVersion":"9.4.0","_npmUser":{"name":"dellamina","email":"mattia.dellamina@gmail.com"},"dist":{"integrity":"sha512-MwDYFrWmGydDgoVOikgTKdBrGUQ6Dg7n7qLvP/I74B2ww4PtvFal2JjVowjpM9XoiKdVHI98xYtNSXpAPTCxkw==","shasum":"a0e73e0873590a8ff8c34ae2da6f2cca68123bd8","tarball":"https://registry.npmjs.org/@dellamina/ts-presenter/-/ts-presenter-0.2.1.tgz","fileCount":9,"unpackedSize":9394,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIH/s4wyvf78AJwqE0V9qqwfCPAtOfQQCp3oCEJ4EcTIsAiBPh+I8vl7seH1uuUiME9ktBHHG6tyUQpy0iCGsI32ETA=="}]},"maintainers":[{"name":"dellamina","email":"mattia.dellamina@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-presenter_0.2.1_1518557038203_0.7225815338211163"},"_hasShrinkwrap":false},"0.2.2":{"author":{"name":"Mattia Della Mina"},"license":"MIT","name":"@dellamina/ts-presenter","version":"0.2.2","description":"Simple view presenters written in typescript using decorators.","main":"./lib/index.js","types":"./lib/index.d.ts","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/dellamina/ts-presenter.git"},"homepage":"https://github.com/dellamina/ts-presenter#readme","bugs":{"url":"https://github.com/dellamina/ts-presenter/issues"},"gitHead":"a4d07634b5ca77953d05b44c8760b53e47ef3ec3","_id":"@dellamina/ts-presenter@0.2.2","_npmVersion":"5.6.0","_nodeVersion":"9.4.0","_npmUser":{"name":"dellamina","email":"mattia.dellamina@gmail.com"},"dist":{"integrity":"sha512-YW2PUkm7ZMZXwiwAUq/6gW3tSJoYoRALqfQyj6D1V8LuQ0BeJzAdRLb9t25ivK+SyvPDaPUQ/T98Jr5VKe8zrg==","shasum":"98bfafe01cbec2d3abb7fff8d1de8b50b66b55cc","tarball":"https://registry.npmjs.org/@dellamina/ts-presenter/-/ts-presenter-0.2.2.tgz","fileCount":9,"unpackedSize":9682,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIH4EoDEBs6gHMpY0NyUxE41sa0MFbXb6MYobqp5GCw4PAiEA79ITh4sWO1xd/hgblrMIr0u6nJloRxuIUreeDhtl9yY="}]},"maintainers":[{"name":"dellamina","email":"mattia.dellamina@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-presenter_0.2.2_1518557635252_0.87331413511938"},"_hasShrinkwrap":false}},"time":{"created":"2018-02-13T21:23:57.861Z","0.2.1":"2018-02-13T21:23:59.144Z","modified":"2022-04-05T03:42:20.254Z","0.2.2":"2018-02-13T21:33:55.966Z"},"maintainers":[{"name":"dellamina","email":"mattia.dellamina@gmail.com"}],"description":"Simple view presenters written in typescript using decorators.","author":{"name":"Mattia Della Mina"},"license":"MIT","readme":"# ts-presenters\r\n\r\nView presenters helps you to keep that bit of logic that needs to be performed before some data is printed in the view out of your model but also out of your view.\r\n\r\n## Install\r\nPull this package through npm\r\n\r\n```\r\nnpm install @dellamina/ts-presenter \r\n``` \r\n\r\n## Usage\r\nFirst you need to create your Presenter, it is just a simple class that extends `Presenter`.\r\nYou have full access to the model you are applying the `Presentable` decorator in the `entity` variable.\r\n\r\n```ts\r\nimport { Presenter } from \"@dellamina/ts-presenter\";\r\n\r\nexport class UserPresenter extends Presenter {\r\n\r\n    fullName = () => {\r\n        return this.entity.name + ' ' + this.entity.surname;\r\n    }\r\n\r\n}\r\n```\r\n\r\nThen we need to add the `Presentable` decorator to our model by passing in the `Presenter` we are going to use, this way every time we gonna have an instance of our model the `Presenter` will be inject to allow us to take advantage of it.\r\n\r\n```ts\r\nimport { Presentable } from \"@dellamina/ts-presenter\";\r\nimport { UserPresenter } from \"./UserPresenter\";\r\n\r\nexport class User {\r\n\r\n    @Presentable(UserPresenter) presenter: UserPresenter;\r\n\r\n    name: string;\r\n    surname: string;\r\n\r\n    constructor(user: { name: string, surname: string }) {\r\n        this.name = user.name;\r\n        this.surname = user.surname;\r\n    }\r\n}\r\n```\r\n\r\nThat's it! You can start using it like so:\r\n```html\r\n<h1>Hello, {{ user.presenter.fullName() }}</h1>\r\n```\r\n\r\nHeavily inspired by [laracasts/Presenter](https://github.com/laracasts/Presenter) from Jeffrey Way","readmeFilename":"README.md","homepage":"https://github.com/dellamina/ts-presenter#readme","repository":{"type":"git","url":"git+https://github.com/dellamina/ts-presenter.git"},"bugs":{"url":"https://github.com/dellamina/ts-presenter/issues"}}