👀 File importing


Our new Edgar Allan website, which we're launching next week 🤫, uses over 3,000 lines of code. It’s a bit unwieldy! To better support the new EA website and similar JavaScript-heavy projects, we’ve added slater_import. This feature allows you to write a function once and then reuse it across all the files in your project. You can see how to use it here. ⬇️

video preview

Not ready to watch the video? No problem. To import a file, simply start typing the name of the file you want to import and click on the code completion dropdown. Once slater_import is added to your code, you can use it right away.

Give it a try and let us know what you think!

Community library scripts

💸 Number to Currency
Formats a string input as US dollar currency without decimal places

📝 Currency to Number
Convert currency string to number by removing non-digit characters and parsing to float.

🔘 Select Radio on Load
Trigger parent element click based on radio button value.

--

Javascript 101: Modular Code

With the addition of slater_import, now is a great time to discuss the concept of modular code. Modular coding is an approach where code is divided into separate, reusable pieces of functionality. Each module or file contains related functions and data that work together to perform a specific task.

The key benefits of writing modular code include improved organization, enhanced maintainability, greater code reusability, easier debugging, and better collaboration in team settings.

Here are a few best practices to help you think more modularly:

  1. Single Responsibility Principle: Each module should focus on one specific functionality, ensuring it does one thing well. This makes your code easier to understand, maintain, and test.
  2. Minimize Dependencies: Reduce coupling between modules to improve flexibility and maintainability. When modules are loosely connected, changes in one module have minimal impact on others, promoting a more robust codebase.
  3. Clear Naming Conventions: Use descriptive names. Clear naming enhances readability and makes it easier for others (and your future self) to understand what each module does.
  4. Consistent Structure: Maintain a consistent organization within your modules. A uniform structure helps developers navigate the codebase more easily, reducing confusion and improving collaboration.
  5. Documentation: Comment your code and provide clear documentation for each module's purpose and usage. Good documentation ensures that others can quickly grasp the intent and functionality of your modules.

Here’s how you can start writing more modular code in Slater:

  1. Create a file for specific functionality.
  2. Import the file by typing its name and selecting it from the dropdown.
  3. Your functions should receive data through parameters.
  4. Your functions should share data through a return statement.

That’s it! Are you already using modular code in your projects?

--

Your projects, supported by Slater

How Money Works is one face of a much larger Webflow-enabled application: howmoneyworks.com.

🤙 the Slater Team

If Slater helps you create better websites, please support the team behind it.

Welcome To Slater!

Slater resources, updates and community activity

Read more from Welcome To Slater!

The team behind Slater would like to wish you a Merry Christmas and a happy New Year! 🎄🎅🎁 Get the Santa ASCII art: https://slater.app/projects/11431/pages/27608 Happy coding! 🤙 the Slater Team If Slater helps you create better websites, please support the team behind it. Become a Pro Slater User

Earlier this year, we built figdam.com. It is currently used by several of our clients to host files and watermark PDFs. We’d like to bring this file hosting functionality to Slater users. With that in mind, where do you currently store files that Webflow doesn’t support? Would this feature be useful to you? What file hosting features do you need? Let us know. JS 101: File types File storage? Javascript? Let's consider all of the different file types that you could host and then retrieve and...

Hi, Just a reminder that Kendra and Mason will be hosting an EA Office Hours Zoom this Friday, the 13th (spooky…) to chat about topics relating to Chapter 1: Sales for Creative Types. Sign up if you can make it, and bring your questions. Let’s get past any lingering sales ick together. Register to join us this Friday, 12/13 here. Also, if you can’t make it this week, we’re thinking about doing it again next Friday, 12/20 as well, if anyone is game? To ring in the holiday break, we’ll chat...