Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

List All Email Templates in Thai Language

Purpose

This script lists all Thai email template files (*_th.html.erb) in the Rails app and writes the result to email_templates_th.txt.

Reference

Email Template Listing Script

Prerequisites

  • Ruby installed
  • Rails project directory available

How to run

  1. Save script as list_th_email_templates.rb.
  2. Run:
ruby list_th_email_templates.rb
  1. Verify output file: email_templates_th.txt.

Script

require 'find'

directory_to_search = 'app/views'
file_pattern = /.*_th\.html\.erb$/
output_file = 'email_templates_th.txt'
matching_files = []

Find.find(directory_to_search) do |path|
  matching_files << path if path =~ file_pattern
end

File.open(output_file, 'w') do |file|
  matching_files.each { |file_path| file.puts(file_path) }
end

puts "Matching files have been listed in #{output_file}"