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

Component creation now allows to be created inside a subdirectory #39

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

vhanla
Copy link

@vhanla vhanla commented Dec 18, 2016

This enhancement as mentioned in #38 will allow to create components inside a convenient subdirectory and by default will prefix its name after the subdirectory that contains it.

For instance, if we are creating a dashboard component for admin and users, one might like to create like this:

php artisan ng:component admin/dashboard

The component will be created inside components directory like: components/admin/admin-dashboard/admin-dashboard.component.js

So if the we want to create another and different dashboard component for users e.g.

php artisan ng:component users/dashboard

It will also be created similarly, but its name will be prefixed to avoid duplicated component names on import.
components/users/users-dashboard/users-dashboard.component.js

So, their names will result in different class names:

class AdminDashboardController{...

class UsersDashboarController{...

However, you can always disable that prepending feature with the added --no-prefix option to allow only using the component name, if that is what you like.

e.g.

php artisan ng:component --no-prefix admin/dashboard

It will be created as components/admin/dashboard/dashboard.component.js and its classname will be class DashboardController{...

So, now ng:component with name that includes subdirectories as mentioned above, is prefixed by default to conveniently avoid duplicated component names... and might also be a hint to help us figure out in which directory is located our component, so we could find it easily. Notice that not using subdirectories, creation of components will behave as usual.

Copy link
Owner

@jadjoubran jadjoubran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please keep the same signature as before?
Also when would --no-prefix be useful?

@rusowyler
Copy link

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants